feat(ImagePreview): fit window resize (#6760)
* feat(ImagePreview): fit window resize * fix(ImagePreview): incorrect max move
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Bind event when mounted or activated
|
||||
*/
|
||||
import { on, off } from '../utils/dom/event';
|
||||
|
||||
let uid = 0;
|
||||
|
||||
export function BindEventMixin(handler) {
|
||||
const key = `binded_${uid++}`;
|
||||
|
||||
function bind() {
|
||||
if (!this[key]) {
|
||||
handler.call(this, on, true);
|
||||
this[key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function unbind() {
|
||||
if (this[key]) {
|
||||
handler.call(this, off, false);
|
||||
this[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
mounted: bind,
|
||||
activated: bind,
|
||||
deactivated: unbind,
|
||||
beforeDestroy: unbind,
|
||||
};
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Bind event when mounted or activated
|
||||
*/
|
||||
import { on, off } from '../utils/dom/event';
|
||||
|
||||
type BindEventMixinThis = {
|
||||
binded: boolean;
|
||||
};
|
||||
|
||||
type BindEventHandler = (bind: Function, isBind: boolean) => void;
|
||||
|
||||
export function BindEventMixin(handler: BindEventHandler) {
|
||||
function bind(this: BindEventMixinThis) {
|
||||
if (!this.binded) {
|
||||
handler.call(this, on, true);
|
||||
this.binded = true;
|
||||
}
|
||||
}
|
||||
|
||||
function unbind(this: BindEventMixinThis) {
|
||||
if (this.binded) {
|
||||
handler.call(this, off, false);
|
||||
this.binded = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
mounted: bind,
|
||||
activated: bind,
|
||||
deactivated: unbind,
|
||||
beforeDestroy: unbind,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user