Add Hover and Freeze #28
AdrianSilvadoNascimento
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Firstly I would like to thank you for this tool, I loved!
I woud like to suggest to add a feature do Hover and Freeze, I had to improve the base code to do this trick.
I you like the ideia, here's the code I implemented using the "grab" mode:
const onLeave = () => {
this.session = null;
this.template.detach();
unListenMove();
unListenLeave();
unListenWheel();
};
const onGrabLeave = () => {
this.template.detach();
unListenMove();
unListenLeave();
unListenWheel();
};
const onGrabOut = () => {
unListenMove();
unListenWheel();
};
const counter = () => {
this.count += 1
}
let unListenMove;
let unListenLeave;
const unListenWheel = this.renderer.listen(this.element.nativeElement, 'wheel', onWheel);
if (this.behavior === 'hover') {
unListenMove = this.renderer.listen(this.element.nativeElement, 'mousemove', onMove);
unListenLeave = this.renderer.listen(this.element.nativeElement, 'mouseleave', onLeave);
}
else if (this.behavior === 'click') {
unListenMove = () => { };
unListenLeave = this.renderer.listen(document, 'mousedown', (downEvent) => {
const element = this.element.nativeElement;
if (!element.contains(downEvent.target)) {
onLeave();
}
});
}
else {
const element = this.element.nativeElement;
counter()
this.isGrabbing = !this.isGrabbing;
if (this.isGrabbing && this.count < 3) {
unListenMove = this.renderer.listen(document, 'mousemove', onMove);
} else {
unListenMove = () => {};
unListenLeave = this.renderer.listen(document, 'mousedown', () => {
onGrabOut();
return
});
}
Beta Was this translation helpful? Give feedback.
All reactions