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

89 lines
1.6 KiB

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