Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected firstUpdated(initProperties: PropertyValues): void {
super.firstUpdated(initProperties);
const container: HTMLSlotElement = this.shadowRoot.querySelector("slot");
// Allow vertical scrolling
const carousel: HTMLDivElement = this.shadowRoot.querySelector("#carousel");
Gestures.addListener(carousel, "track", this._drag.bind(this));
this.setScrollDirection("all", carousel);
this.children = FlattenedNodesObserver.getFlattenedNodes(container)
// @ts-ignore
.filter((n: HTMLElement) => {
return n.nodeType === Node.ELEMENT_NODE;
});
// Handle transition end
const items = this.shadowRoot.querySelector("#items");
items.addEventListener("transitionend", (e: any) => {
e.preventDefault();
if (this.swiping || e.propertyName !== "transform") {
return;
}
this.animating = false;
});
_attachEvents() {
if (!this._knobAttached) {
addListener(this._knob, 'down', (event) => {
if (!this.disabled) {
this._knobdown(event);
}
});
addListener(this._knob, 'up', (event) => {
if (!this.disabled) {
this._resetKnob(event);
}
});
addListener(this._knob, 'track', (event) => {
if (!this.disabled) {
this._onTrack(event);
}
});
this._knobAttached = true;
}
_attachEvents() {
if (!this._knobAttached) {
addListener(this._knob, 'down', (event) => {
if (!this.disabled) {
this._knobdown(event);
}
});
addListener(this._knob, 'up', (event) => {
if (!this.disabled) {
this._resetKnob(event);
}
});
addListener(this._knob, 'track', (event) => {
if (!this.disabled) {
this._onTrack(event);
}
});
this._knobAttached = true;
}
if (!this._keyboardAttached) {
this.addEventListener('keydown', (event) => {
switch (event.keyCode) {
case 38:
case 39:
_addActiveListeners() {
addListener(this, 'down', () => !this.disabled && this.setAttribute('active', ''));
addListener(this, 'up', () => this.removeAttribute('active'));
this.addEventListener(
'keydown',
e => !this.disabled && [13, 32].indexOf(e.keyCode) >= 0 && this.setAttribute('active', '')
);
this.addEventListener('keyup', () => this.removeAttribute('active'));
this.addEventListener('blur', () => this.removeAttribute('active'));
}
updated(changedProperties) {
if (changedProperties.has('noGestures')) {
if (this.noGestures) {
Gestures.removeListener(this, 'track', this._boundTrackHandler);
} else {
Gestures.addListener(this, 'track', this._boundTrackHandler);
}
}
}
_attachEvents() {
if (!this._knobAttached) {
addListener(this._knob, 'down', (event) => {
if (!this.disabled) {
this._knobdown(event);
}
});
addListener(this._knob, 'up', (event) => {
if (!this.disabled) {
this._resetKnob(event);
}
});
addListener(this._knob, 'track', (event) => {
if (!this.disabled) {
this._onTrack(event);
}
});
this._knobAttached = true;
}
if (!this._keyboardAttached) {
this.addEventListener('keydown', (event) => {
switch (event.keyCode) {
case 38:
case 39:
this._incremenent();
break;
case 37:
case 40:
this._decrement();
_attachEvents() {
if (!this._knobAttached) {
addListener(this._knob, 'down', (event) => {
if (!this.disabled) {
this._knobdown(event);
}
});
addListener(this._knob, 'up', (event) => {
if (!this.disabled) {
this._resetKnob(event);
}
});
addListener(this._knob, 'track', (event) => {
if (!this.disabled) {
this._onTrack(event);
}
});
this._knobAttached = true;
}