mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.8 KiB
121 lines
2.8 KiB
/* generated by Svelte vX.Y.Z */
|
|
import {
|
|
SvelteComponent,
|
|
add_render_callback,
|
|
add_resize_listener,
|
|
detach,
|
|
element,
|
|
init,
|
|
insert,
|
|
listen,
|
|
noop,
|
|
raf,
|
|
run_all,
|
|
safe_not_equal
|
|
} from "svelte/internal";
|
|
|
|
function create_fragment(ctx) {
|
|
let video;
|
|
let video_updating = false;
|
|
let video_resize_listener;
|
|
let video_animationframe;
|
|
let dispose;
|
|
|
|
function video_timeupdate_handler() {
|
|
cancelAnimationFrame(video_animationframe);
|
|
|
|
if (!video.paused) {
|
|
video_animationframe = raf(video_timeupdate_handler);
|
|
video_updating = true;
|
|
}
|
|
|
|
ctx.video_timeupdate_handler.call(video);
|
|
}
|
|
|
|
return {
|
|
c() {
|
|
video = element("video");
|
|
add_render_callback(() => ctx.video_elementresize_handler.call(video));
|
|
if (ctx.videoHeight === void 0 || ctx.videoWidth === void 0) add_render_callback(() => ctx.video_resize_handler.call(video));
|
|
|
|
dispose = [
|
|
listen(video, "timeupdate", video_timeupdate_handler),
|
|
listen(video, "resize", ctx.video_resize_handler)
|
|
];
|
|
},
|
|
m(target, anchor) {
|
|
insert(target, video, anchor);
|
|
video_resize_listener = add_resize_listener(video, ctx.video_elementresize_handler.bind(video));
|
|
},
|
|
p(changed, ctx) {
|
|
if (!video_updating && changed.currentTime && !isNaN(ctx.currentTime)) {
|
|
video.currentTime = ctx.currentTime;
|
|
}
|
|
|
|
video_updating = false;
|
|
},
|
|
i: noop,
|
|
o: noop,
|
|
d(detaching) {
|
|
if (detaching) detach(video);
|
|
video_resize_listener.cancel();
|
|
run_all(dispose);
|
|
}
|
|
};
|
|
}
|
|
|
|
function instance($$self, $$props, $$invalidate) {
|
|
let { currentTime } = $$props;
|
|
let { videoHeight } = $$props;
|
|
let { videoWidth } = $$props;
|
|
let { offsetWidth } = $$props;
|
|
|
|
function video_elementresize_handler() {
|
|
offsetWidth = this.offsetWidth;
|
|
$$invalidate("offsetWidth", offsetWidth);
|
|
}
|
|
|
|
function video_timeupdate_handler() {
|
|
currentTime = this.currentTime;
|
|
$$invalidate("currentTime", currentTime);
|
|
}
|
|
|
|
function video_resize_handler() {
|
|
videoHeight = this.videoHeight;
|
|
videoWidth = this.videoWidth;
|
|
$$invalidate("videoHeight", videoHeight);
|
|
$$invalidate("videoWidth", videoWidth);
|
|
}
|
|
|
|
$$self.$set = $$props => {
|
|
if ("currentTime" in $$props) $$invalidate("currentTime", currentTime = $$props.currentTime);
|
|
if ("videoHeight" in $$props) $$invalidate("videoHeight", videoHeight = $$props.videoHeight);
|
|
if ("videoWidth" in $$props) $$invalidate("videoWidth", videoWidth = $$props.videoWidth);
|
|
if ("offsetWidth" in $$props) $$invalidate("offsetWidth", offsetWidth = $$props.offsetWidth);
|
|
};
|
|
|
|
return {
|
|
currentTime,
|
|
videoHeight,
|
|
videoWidth,
|
|
offsetWidth,
|
|
video_elementresize_handler,
|
|
video_timeupdate_handler,
|
|
video_resize_handler
|
|
};
|
|
}
|
|
|
|
class Component extends SvelteComponent {
|
|
constructor(options) {
|
|
super();
|
|
|
|
init(this, options, instance, create_fragment, safe_not_equal, {
|
|
currentTime: 0,
|
|
videoHeight: 0,
|
|
videoWidth: 0,
|
|
offsetWidth: 0
|
|
});
|
|
}
|
|
}
|
|
|
|
export default Component; |