seleccion-articulos.component.ts
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-seleccion-articulos",
templateUrl: "./seleccion-articulos.component.html",
styleUrls: ["./seleccion-articulos.component.scss"]
})
export class SeleccionArticulosComponent implements OnInit {
timeoutHandler: any;
categorias = [
{ id: 1, selected: false },
{ id: 2, selected: false },
{ id: 3, selected: false }
];
constructor() {}
ngOnInit() {}
selectCategoria(index: number) {
this.categorias.forEach((categoria, i) => {
categoria.selected = index === i ? true : false;
});
}
mouseup() {
if (!this.timeoutHandler) return;
clearInterval(this.timeoutHandler);
}
scrollY(el: HTMLElement, value) {
el.scroll({ behavior: "smooth", top: value + el.scrollTop });
this.timeoutHandler = setInterval(() => {
el.scroll({ behavior: "smooth", top: value + el.scrollTop });
}, 500);
}
scrollX(el: HTMLElement, value) {
el.scroll({ behavior: "smooth", left: value + el.scrollLeft });
this.timeoutHandler = setInterval(() => {
el.scroll({ behavior: "smooth", left: value + el.scrollLeft });
}, 500);
}
}