Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some events(full,exit,render) #604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add rendered events options
  • Loading branch information
tanlng committed Jun 27, 2023
commit 1985d42da6046d04dba0b30bf9d3651ced3c558f
14 changes: 11 additions & 3 deletions src/js/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getImageNaturalSizes,
getTransforms,
hasClass,
isFunction,
isNumber,
removeClass,
removeListener,
Expand Down Expand Up @@ -275,13 +276,20 @@ export default {
marginTop: imageData.y,
}, getTransforms(imageData)));

if (done) {
if (done || isFunction(this.options.rendered)) {
const callback = () => {
done();
if (isFunction(this.options.rendered)) {
this.options.rendered();
}
};

if ((this.viewing || this.moving || this.rotating || this.scaling || this.zooming)
&& this.options.transition
&& hasClass(image, CLASS_TRANSITION)) {
const onTransitionEnd = () => {
this.imageRendering = false;
done();
callback();
};

this.imageRendering = {
Expand All @@ -294,7 +302,7 @@ export default {
once: true,
});
} else {
done();
callback();
}
}
},
Expand Down