Git Product home page Git Product logo

Comments (8)

FRSgit avatar FRSgit commented on May 31, 2024 1

Hey @BoumBam! It took a while, but I've figured out the solution here: https://jsfiddle.net/mjareo0d/4/
It might not be the prettiest piece of code out there, but it gets the job done. The problem with emojionearea is that they don't expose most of their API publicly, so there is not much more we can do :<
This code could be much better if they would give us some kind of right before ready event, so we can do the work before their own button initialisation happen, but after the EmojiOneArea instance would be created.

Hope the code from fiddle linked above fixes the problem for you - give me a sign if it does! Cheers ;)

from default-passive-events.

FRSgit avatar FRSgit commented on May 31, 2024 1

In the code I've posted I'm basically overwrite default jQuery .on() method with my own implementation to catch all .emojionearea-picker,.emojionearea-button elements. This part

[0].emojioneArea.on('ready', function () {
    $.fn.on = originalOn;
});

is needed to bring back the default .on() implementation, so yea, I would say you probably want to use this piece of code as well.

from default-passive-events.

FRSgit avatar FRSgit commented on May 31, 2024

Hey! Sorry, I haven't see this issue earlier:<

So, there is a possibility to disable this library for some elements. There is a notice in Q&A section of our README on how to disable default-passive-events for a single element:
https://github.com/zzarcon/default-passive-events/blob/master/README.md#is-there-a-possibility-to-bring-default-addeventlistener-method-back-for-chosen-elementsglobally-eg-for-time-of-running-some-of-the-code

So, having this piece of code, you could've tweak it a bit to restore original addEventListener implementation for all elements having the same, one class:

document.body.querySelectorAll('.emojionearea-editor').forEach(function (element) {
    element.addEventListener = element.addEventListener._original;
});

from default-passive-events.

FRSgit avatar FRSgit commented on May 31, 2024

Once again - sorry for such a late response. Does this answers your question?

from default-passive-events.

BoumBam avatar BoumBam commented on May 31, 2024

don't worry my friends for your late answer.

But I can't arrive to make your plug-in compatible with https://github.com/mervick/emojionearea

Here is the normal state:
When I remove your plug-in from my project https://jsfiddle.net/aeLkgzju/

Here is the anomalous state:
When I add your plug-in in my project https://jsfiddle.net/8q9d3rzj/

In anomalous state when I click on an emoji, the emoji picker is closed and the emoji is inserted at the beginning of the .emojionearea-editor instead of the actual cursor position.

Have you find the problem ?

Can you help me ?

from default-passive-events.

BoumBam avatar BoumBam commented on May 31, 2024

Using only the code below seem to work

`const originalOn = $.fn.on;
      $.fn.on = function () {
        const items = this;
        let result;
        const customAddEventListeners = items.map(function() {
          if (this.classList && (
            this.classList.contains('emojionearea-picker') ||
            this.classList.contains('emojionearea-button')
          )) {
            const customAddEventListener = this.addEventListener;
            this.addEventListener = this.addEventListener._original;
            return customAddEventListener;
          }
        });
        result = originalOn.apply(this, arguments);
        customAddEventListeners.each(function (i) {
          if (this) {
            items[i].addEventListener = this;
          }
        });
        return result;
      };
      $("#textarea_post_wall,.wall_post_share_text_textarea").emojioneArea({
        pickerPosition: "right",
        search: false,
        buttonTitle: ""  
      });`

Is the below code necessary ?:

`[0].emojioneArea.on('ready', function () {
        $.fn.on = originalOn;
      });`

Thanks a lot.

from default-passive-events.

BoumBam avatar BoumBam commented on May 31, 2024

As you suggest, I think I must use it to avoid potential problem.
You are a javaScript master.

Thanks alot.

from default-passive-events.

FRSgit avatar FRSgit commented on May 31, 2024

Thanks, happy to help! 🆘
Sorry that it took so long though, happy coding 🚀

from default-passive-events.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.