Comments (8)
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.
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.
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.
Once again - sorry for such a late response. Does this answers your question?
from default-passive-events.
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.
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.
As you suggest, I think I must use it to avoid potential problem.
You are a javaScript master.
Thanks alot.
from default-passive-events.
Thanks, happy to help! 🆘
Sorry that it took so long though, happy coding 🚀
from default-passive-events.
Related Issues (20)
- Unable to preventDefault inside passive event listener invocation. HOT 2
- 404 page demo.html HOT 5
- The routine doesn't work for YouTube videos embedded in iFrames HOT 8
- Error in console - Cannot read property 'capture' of null HOT 9
- Store link to original preventDefault method under separate property name HOT 8
- Broken `removeEventListener` HOT 1
- Doesn't work, even the example page HOT 4
- Question: add new types of events HOT 5
- Cursor event not work while jquery is appending new content. HOT 2
- this is not an issue as it seems HOT 2
- Issue with Select2 plugin HOT 3
- Question: where should I place the script to get the best result HOT 1
- About scroll event HOT 1
- Integration with Smooth Scroll e.g Locomotive Scroll HOT 2
- Remove sourceMappingURL from dist HOT 3
- Ability to provide/limit list of events
- CDN link 404 error HOT 1
- Unable to preventDefault inside passive event listener HOT 1
- Planned removal of crucial DOM events HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from default-passive-events.