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.
68 lines
1.5 KiB
68 lines
1.5 KiB
/* generated by Svelte vX.Y.Z */
|
|
import { appendNode, assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js";
|
|
|
|
function create_main_fragment(state, component) {
|
|
var window_updating = false, text, p, text_1, text_2;
|
|
|
|
function onwindowscroll(event) {
|
|
window_updating = true;
|
|
|
|
component.set({
|
|
y: this.scrollY
|
|
});
|
|
window_updating = false;
|
|
};
|
|
window.addEventListener("scroll", onwindowscroll);
|
|
|
|
component.observe("y", function(y) {
|
|
if (window_updating) return;
|
|
window.scrollTo(window.scrollX, y);
|
|
});
|
|
|
|
return {
|
|
c: function create() {
|
|
text = createText("\n\n");
|
|
p = createElement("p");
|
|
text_1 = createText("scrolled to ");
|
|
text_2 = createText(state.y);
|
|
},
|
|
|
|
m: function mount(target, anchor) {
|
|
insertNode(text, target, anchor);
|
|
insertNode(p, target, anchor);
|
|
appendNode(text_1, p);
|
|
appendNode(text_2, p);
|
|
},
|
|
|
|
p: function update(changed, state) {
|
|
if (changed.y) {
|
|
text_2.data = state.y;
|
|
}
|
|
},
|
|
|
|
u: function unmount() {
|
|
detachNode(text);
|
|
detachNode(p);
|
|
},
|
|
|
|
d: function destroy() {
|
|
window.removeEventListener("scroll", onwindowscroll);
|
|
}
|
|
};
|
|
}
|
|
|
|
function SvelteComponent(options) {
|
|
init(this, options);
|
|
this._state = assign({}, options.data);
|
|
this._state.y = window.scrollY;
|
|
|
|
this._fragment = create_main_fragment(this._state, this);
|
|
|
|
if (options.target) {
|
|
this._fragment.c();
|
|
this._fragment.m(options.target, options.anchor || null);
|
|
}
|
|
}
|
|
|
|
assign(SvelteComponent.prototype, proto);
|
|
export default SvelteComponent; |