rodneyrehm / viewport-units-buggyfill

Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari.
MIT License
1.59k stars 151 forks source link

Custom event for style updates #63

Closed henryruhs closed 9 years ago

henryruhs commented 9 years ago

Can be tested this way:

$(window).on('viewport-units-buggyfill-style', function (event) {
    alert(event.type);
});
henryruhs commented 9 years ago

It would be great to have custom viewport-units-buggyfill-init too but I don't know the right place were to put it to...

rodneyrehm commented 9 years ago

PR for issue #62


This is going to fail in IE10 and older, because it does not know the CustomEvent constructor. You'll need to add a polyfill for this.

It would be great to have custom viewport-units-buggyfill-init too but I don't know the right place were to put it to...

what do you intend to do with it? I'd say before initializing the hacks is a good time?

henryruhs commented 9 years ago

I'd like to add and remove classes to hide parts in the website that will be processed and look ugly before the buggyfill finished processing.

$(window).on('viewport-units-buggyfill-init viewport-units-buggyfill-style', function (event) {
    if (event.type === 'viewport-units-buggyfill-init') {
    //add buggy class to hide something
    } else {
    //remove buggy class to hide something
    }
});
henryruhs commented 9 years ago

Were is the best place to add the polyfill inside your core?

rodneyrehm commented 9 years ago

Were is the best place to add the polyfill inside your core?

since we're talking about few lines of code, I guess I'd just copy-paste it (with linking to the source) before the private functions.

henryruhs commented 9 years ago

Let me test it once you merged it to the master.

rodneyrehm commented 9 years ago

Why do you need this merged to master to test it?

bower link $moduleName
npm link $moduleName
henryruhs commented 9 years ago

I allready tested it with my fork, but not with the polyfill.

rodneyrehm commented 9 years ago

I don't understand. you still need to add the polyfill to your PR anyway?!

henryruhs commented 9 years ago

Lost in conversation, I thought you are going to add it. Anyway - I updated my fork. The pull request can be merged.