Skip to content

Commit

Permalink
Fix IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsnik committed Jul 7, 2018
1 parent 14efb34 commit dc35a70
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
mirror: true
});

document.addEventListener('aos:in', ({ detail }) => {
console.log('in!', detail);
document.addEventListener('aos:in', function(e) {
console.log('in!', e.detail);
});

window.addEventListener('scroll', function() {
scrollCounter.innerHTML = window.scrollY;
scrollCounter.innerHTML = window.pageYOffset;
});
}
</script>
Expand Down
8 changes: 8 additions & 0 deletions src/js/helpers/detector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions src/js/helpers/handleScroll.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import detect from './detector';

/**
* Adds multiple classes on node
* @param {DOMNode} node
Expand All @@ -15,9 +17,17 @@ const removeClasses = (node, classes) =>
classes && classes.forEach(className => node.classList.remove(className));

const fireEvent = (eventName, data) => {
const customEvent = new CustomEvent(eventName, {
detail: data
});
let customEvent;

if (detect.ie11()) {
customEvent = document.createEvent('CustomEvent');
customEvent.initCustomEvent(eventName, true, true, { detail: data });
} else {
customEvent = new CustomEvent(eventName, {
detail: data
});
}

return document.dispatchEvent(customEvent);
};

Expand Down
7 changes: 3 additions & 4 deletions src/js/helpers/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const prepare = function($elements, options) {
const customClassNames =
options.useClassNames && el.node.getAttribute('data-aos');

const animatedClassNames = [
options.animatedClassName,
...(customClassNames && customClassNames.split(' '))
].filter(className => typeof className === 'string');
const animatedClassNames = [options.animatedClassName]
.concat(customClassNames ? customClassNames.split(' ') : [])
.filter(className => typeof className === 'string');

if (options.initClassName) {
el.node.classList.add(options.initClassName);
Expand Down

0 comments on commit dc35a70

Please sign in to comment.