さて、私はそれを理解しました。他の人を助ける場合に備えてここに掲載します。この解決策では、prototypeと、registerEvent、getElementX、およびgetElementY関数を提供する内部ライブラリを使用します。
var MenuManager = Class.create({
initialize: function initialize(menuElt) {
this.menu = $(menuElt);
this.homePosn = { x: getElementX(this.menu), y: getElementY(this.menu) };
registerEvent(document, 'scroll', this.handleScroll.bind(this));
this.handleScroll();
},
handleScroll: function handleScroll() {
this.scrollOffset = document.viewport.getScrollOffsets().top;
if (this.scrollOffset > this.homePosn.y) {
this.menu.style.position = 'fixed';
this.menu.style.top = 0;
this.menu.style.left = this.homePosn.x;
} else {
this.menu.style.position = 'absolute';
this.menu.style.top = null;
this.menu.style.left = null;
}
}
});
あなたのメニューのIDでコンストラクタを呼び出すと、そこから継承されます。
サイドノート:一部の人々は、そのメニューを憎みます。それを取り除くすべてのGreasemonkeyスクリプトを見てみましょう。 –
@Chase、私が含まれています。 –