Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function detachEvents() {
const swiper = this;
const {
params, touchEvents, el, wrapperEl,
} = swiper;
const capture = !!params.nested;
// Touch Events
if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
}
// Prevent Links Clicks
if (params.preventClicks || params.preventClicksPropagation) {
el.removeEventListener('click', swiper.onClick, true);
}
if (params.cssMode) {
wrapperEl.removeEventListener('scroll', swiper.onScroll);
}
// Resize handler
swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize);
}
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
}
// Prevent Links Clicks
if (params.preventClicks || params.preventClicksPropagation) {
el.removeEventListener('click', swiper.onClick, true);
}
if (params.cssMode) {
wrapperEl.removeEventListener('scroll', swiper.onScroll);
}
// Resize handler
swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize);
}
function detachEvents() {
const swiper = this;
const {
params, touchEvents, el, wrapperEl,
} = swiper;
const capture = !!params.nested;
// Touch Events
if (!Support.touch && Support.pointerEvents) {
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
}
function detachEvents() {
const swiper = this;
const {
params, touchEvents, el, wrapperEl,
} = swiper;
const capture = !!params.nested;
// Touch Events
if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
}
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
}
// Prevent Links Clicks
if (params.preventClicks || params.preventClicksPropagation) {
el.removeEventListener('click', swiper.onClick, true);
}
if (params.cssMode) {
wrapperEl.removeEventListener('scroll', swiper.onScroll);
}
// Resize handler
swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize);
}
function detachEvents() {
const swiper = this;
const {
params, touchEvents, el, wrapperEl,
} = swiper;
const capture = !!params.nested;
// Touch Events
if (!Support.touch && Support.pointerEvents) {
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
} else {
if (Support.touch) {
const passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
if (touchEvents.cancel) {
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
}
}
if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
el.removeEventListener('mousedown', swiper.onTouchStart, false);
document.removeEventListener('mousemove', swiper.onTouchMove, capture);
document.removeEventListener('mouseup', swiper.onTouchEnd, false);
}
disableDraggable() {
const swiper = this;
if (!swiper.params.scrollbar.el) return;
const {
scrollbar, touchEventsTouch, touchEventsDesktop, params,
} = swiper;
const $el = scrollbar.$el;
const target = $el[0];
const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
if (!Support.touch) {
target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
} else {
target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
}
},
init() {
disableDraggable() {
const swiper = this;
if (!swiper.params.scrollbar.el) return;
const {
scrollbar, touchEventsTouch, touchEventsDesktop, params,
} = swiper;
const $el = scrollbar.$el;
const target = $el[0];
const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
if (!Support.touch) {
target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
} else {
target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
}
},
init() {
disableDraggable() {
const swiper = this;
if (!swiper.params.scrollbar.el) return;
const {
scrollbar, touchEventsTouch, touchEventsDesktop, params,
} = swiper;
const $el = scrollbar.$el;
const target = $el[0];
const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
if (!Support.touch) {
target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
} else {
target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
}
},
init() {