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.
svelte/test/js/samples/window-binding-scroll/expected.js

88 lines
1.6 KiB

/* generated by Svelte vX.Y.Z */
6 years ago
import {
SvelteComponent,
6 years ago
add_render_callback,
append,
detach,
element,
init,
insert,
listen,
noop,
safe_not_equal,
set_data,
text
} from "svelte/internal";
function create_fragment(ctx) {
6 years ago
var scrolling = false, clear_scrolling = () => { scrolling = false }, scrolling_timeout, p, t0, t1, dispose;
add_render_callback(ctx.onwindowscroll);
return {
7 years ago
c() {
6 years ago
p = element("p");
t0 = text("scrolled to ");
t1 = text(ctx.y);
dispose = listen(window, "scroll", () => {
scrolling = true;
clearTimeout(scrolling_timeout);
scrolling_timeout = setTimeout(clear_scrolling, 100);
ctx.onwindowscroll();
});
},
7 years ago
m(target, anchor) {
insert(target, p, anchor);
6 years ago
append(p, t0);
append(p, t1);
},
7 years ago
p(changed, ctx) {
if (changed.y && !scrolling) {
scrolling = true;
clearTimeout(scrolling_timeout);
window.scrollTo(window.pageXOffset, ctx.y);
scrolling_timeout = setTimeout(clear_scrolling, 100);
}
if (changed.y) {
6 years ago
set_data(t1, ctx.y);
}
},
i: noop,
o: noop,
6 years ago
d(detaching) {
if (detaching) {
detach(p);
7 years ago
}
dispose();
}
};
}
function instance($$self, $$props, $$invalidate) {
let { y } = $$props;
function onwindowscroll() {
y = window.pageYOffset; $$invalidate('y', y);
}
6 years ago
$$self.$set = $$props => {
if ('y' in $$props) $$invalidate('y', y = $$props.y);
};
return { y, onwindowscroll };
}
class Component extends SvelteComponent {
constructor(options) {
super();
6 years ago
init(this, options, instance, create_fragment, safe_not_equal, ["y"]);
}
}
export default Component;