答えてくれた@Ryanに感謝します。これはまさに私が探していたものです。私はあなたのコードをもう少し進めて、より多くの機能を提供しました。
次のことを行うために、tippy に 2 つの新しいオプションを追加しました。
- /では、
sw
またはnw
を使用できedgeAlignWest: 'right'
ますedgeAlignWest: 'center'
- /では、
se
またはne
を使用できedgeAlignEast: 'left'
ますedgeAlignEast: 'center'
これを行う新しいコードは
// line 61, tipsy version 1.0.0a
if (gravity.length == 2) {
if (gravity.charAt(1) == 'e') {
tp.left = (this.options.edgeAlignEast == 'right') ? (pos.left + pos.width - actualWidth + 15) : (pos.left + pos.width / 2 - actualWidth + 15);
}else if (gravity.charAt(1) == 'w') {
tp.left = (this.options.edgeAlignWest == 'left') ? (pos.left - 5) : (pos.left + pos.width / 2 - 15);
} else {
tp.left = pos.left + pos.width / 2 - actualWidth + 15;
}
}
//...
// line 191, tipsy version 1.0.0a
$.fn.tipsy.defaults = {
edgeAlignEast: 'center', // <-- new option, default to 'center', you can also use 'right'
edgeAlignWest: 'center', // <-- new option, default to 'center', you can also use 'left'
className: null,
delayIn: 0,
delayOut: 0,
fade: false,
fallback: '',
gravity: 'n',
html: false,
live: false,
offset: 0,
opacity: 0.8,
title: 'title',
trigger: 'hover'
};