Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false triggering of mouse clicks when banners are scrolled #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .eslintrc.js
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmignore
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified dist/siema.min.js
100644 → 100755
Empty file.
Empty file modified docs/_layouts/default.html
100644 → 100755
Empty file.
Empty file modified docs/assets/android-chrome-192x192.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/android-chrome-256x256.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/apple-touch-icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/browserconfig.xml
100644 → 100755
Empty file.
Empty file modified docs/assets/bs.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/favicon-16x16.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/favicon-32x32.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/favicon.ico
100644 → 100755
Empty file.
Empty file modified docs/assets/manifest.json
100644 → 100755
Empty file.
Empty file modified docs/assets/mstile-150x150.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/safari-pinned-tab.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/siema--pink.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/siema--yellow.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/siema.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/siema.min.js
100644 → 100755
Empty file.
Empty file modified docs/assets/siema.mp4
100644 → 100755
Empty file.
Empty file modified docs/assets/siema.webm
100644 → 100755
Empty file.
Empty file modified docs/assets/siematutorial.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/style.css
100644 → 100755
Empty file.
Empty file modified docs/index.md
100644 → 100755
Empty file.
Empty file modified package-lock.json
100644 → 100755
Empty file.
Empty file modified package.json
100644 → 100755
Empty file.
31 changes: 29 additions & 2 deletions src/siema.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/**
* Hi :-) This is a class representing a Siema.
*/
export default class Siema {
class Siema {
/**
* Create a Siema.
* @param {Object} options - Optional settings object.
*/
constructor(options) {
//class vars
this.preventClickFlag = false;

// Merge defaults with user's settings
this.config = Siema.mergeSettings(options);

Expand All @@ -25,7 +28,7 @@ export default class Siema {
this.transformProperty = Siema.webkitOrNot();

// Bind all event handlers for referencability
['resizeHandler', 'touchstartHandler', 'touchendHandler', 'touchmoveHandler', 'mousedownHandler', 'mouseupHandler', 'mouseleaveHandler', 'mousemoveHandler'].forEach(method => {
['resizeHandler', 'touchstartHandler', 'touchendHandler', 'touchmoveHandler', 'mousedownHandler', 'mouseupHandler', 'mouseleaveHandler', 'mousemoveHandler', 'mouseclickHandler'].forEach(method => {
this[method] = this[method].bind(this);
});

Expand All @@ -50,6 +53,7 @@ export default class Siema {
multipleDrag: true,
threshold: 20,
loop: false,
autorotate: 3000,
onInit: () => {},
onChange: () => {},
};
Expand Down Expand Up @@ -103,6 +107,7 @@ export default class Siema {
this.selector.addEventListener('mouseup', this.mouseupHandler);
this.selector.addEventListener('mouseleave', this.mouseleaveHandler);
this.selector.addEventListener('mousemove', this.mousemoveHandler);
this.selector.addEventListener('click', this.mouseclickHandler);
}
}

Expand All @@ -116,6 +121,7 @@ export default class Siema {
this.selector.removeEventListener('touchstart', this.touchstartHandler);
this.selector.removeEventListener('touchend', this.touchendHandler);
this.selector.removeEventListener('touchmove', this.touchmoveHandler);
this.selector.removeEventListener('click', this.mouseclickHandler);
this.selector.removeEventListener('mousedown', this.mousedownHandler);
this.selector.removeEventListener('mouseup', this.mouseupHandler);
this.selector.removeEventListener('mouseleave', this.mouseleaveHandler);
Expand Down Expand Up @@ -168,6 +174,7 @@ export default class Siema {
// Go to currently active slide after initial build
this.slideToCurrent();
this.config.onInit.call(this);
this.config.autorotate !== undefined ? this.autorotate() : null;
}


Expand Down Expand Up @@ -239,6 +246,15 @@ export default class Siema {
}
}
}

/**
* autorotate
*/
autorotate() {
if(this.config.autorotate !== undefined && this.config.autorotate != 0){
let timerId = setTimeout( () => {this.next(); this.autorotate();}, this.config.autorotate);
}
}


/**
Expand Down Expand Up @@ -378,6 +394,7 @@ export default class Siema {
* mousedown event handler
*/
mousedownHandler(e) {
this.preventClickFlag = false;
// Prevent dragging / swiping on inputs, selects and textareas
const ignoreSiema = ['TEXTAREA', 'OPTION', 'INPUT', 'SELECT'].indexOf(e.target.nodeName) !== -1;
if (ignoreSiema) {
Expand Down Expand Up @@ -411,6 +428,7 @@ export default class Siema {
* mousemove event handler
*/
mousemoveHandler(e) {
this.preventClickFlag = true;
e.preventDefault();
if (this.pointerDown) {
this.drag.endX = e.pageX;
Expand All @@ -420,6 +438,15 @@ export default class Siema {
this.sliderFrame.style[this.transformProperty] = `translate3d(${(this.currentSlide * (this.selectorWidth / this.perPage) + (this.drag.startX - this.drag.endX)) * -1}px, 0, 0)`;
}
}

/**
* mouseclick event handler
*/
mouseclickHandler(e) {
if(this.preventClickFlag){
e.preventDefault();
}
}


/**
Expand Down
Empty file modified webpack.config.js
100644 → 100755
Empty file.
Empty file modified yarn.lock
100644 → 100755
Empty file.