Tooltipster无法在移动设备上运行 - Wordpress

时间:2017-02-28 19:35:27

标签: jquery wordpress tooltipster

加载Tooltipster jquery插件以触发工具提示"在悬停"状态。

在移动设备上,"悬停"触发器无法加载 - 因此我想将触发器更改为"单击"在移动设备上。

我在tooltipster.core.js中尝试了以下编辑: 但这只会禁用工具提示,并且不会更改"触发器"点击 ...触发器:'点击',从触发器更改:' hover',

var defaults = {
        animation: 'fade',
        animationDuration: 350,
        content: null,
        contentAsHTML: false,
        contentCloning: false,
        debug: true,
        delay: 300,
        delayTouch: [300, 500],
        functionInit: null,
        functionBefore: null,
        functionReady: null,
        functionAfter: null,
        functionFormat: null,
        IEmin: 6,
        interactive: false,
        multiple: false,
        // must be 'body' for now, or an element positioned at (0, 0)
        // in the document, typically like the very top views of an app.
        parent: 'body',
        plugins: ['sideTip'],
        repositionOnScroll: false,
        restoration: 'none',
        selfDestruction: true,
        theme: [],
        timer: 0,
        trackerInterval: 500,
        trackOrigin: false,
        trackTooltip: false,
        trigger: 'click',
        triggerClose: {
            click: false,
            mouseleave: false,
            originClick: false,
            scroll: false,
            tap: false,
            touchleave: false
        },
        triggerOpen: {
            click: false,
            mouseenter: false,
            tap: false,
            touchstart: false
        },
        updateAnimation: 'rotate',
        zIndex: 9999999
    },

2 个答案:

答案 0 :(得分:4)

BIG EDIT

(如果您愿意,请查看历史记录,我只留下与工作解决方案相关的内容)


好的,首先,如果您修改了任何ToolTipster插件文件,只需撤消所有更改或下载并重新安装新文件。

那就是说,当我在评论中谈到“init”时,我在谈论实例化ToolTipster函数的脚本......在你的网页内容中。

根据ToolTipster的文档,Instantiating ToolTipster插件可以执行您想要的操作(在点击/点击时打开/关闭工具提示,而不是悬停)以这种方式完成,介于<body>和{之间{1}}代码:

使用</body>trigger:"custom",参数需要

triggerOpen 实际上,它只是将所有内置触发器事件侦听器设置为false,并允许设置自定义触发器。

triggerClose



现在在链接

上使用它

(这是我通过尝试完成的可选工作)

由于默认情况下链接会打开<script> $(document).ready(function(){ $('.tooltip').tooltipster({ animation: 'fade', delay: 200, theme: 'tooltipster-punk', trigger:"custom", triggerOpen: { click: true, // For mouse tap: true // For touch device }, triggerClose: { click: true, // For mouse tap: true // For touch device } }); }); </script> ,因此您可能希望它不会... ... 并使用href事件来打开链接 (你必须提及你的用户关于这个“不寻常的”双击事物)
;)



我在下面的片段中完成了所有这些 请注意,SO正在阻止代码段打开在代码段沙箱中... It is working great in CodePen

dblclick
$('#myPageTitle').tooltipster({
  animation: 'fade',
  delay: 200,
  theme: 'tooltipster-punk',
  trigger:'custom',
  content: "Welcome to my new website.",
  triggerOpen: {
    click: true,  // For mouse
    tap: true    // For touch device
  },
  triggerClose: {
    click: true,  // For mouse
    tap: true    // For touch device
    }
});

$('.coolLink').tooltipster({
  animation: 'fade',
  delay: 200,
  theme: 'tooltipster-punk',
  trigger:"custom",
  content: "This is a cool link to visit! Double-click! (not working on SO)",
  triggerOpen: {
    click: true,  // For mouse
    tap: true    // For touch device
  },
  triggerClose: {
    click: true,  // For mouse
    tap: true    // For touch device
  }
});

$('#eoi').tooltipster({
  animation: 'fade',
  delay: 200,
  theme: 'tooltipster-punk',
  trigger:"custom",
  content: "This is the End of Internet.",
  triggerOpen: {
    click: true,  // For mouse
    tap: true    // For touch device
  },
  triggerClose: {
    click: true,  // For mouse
    tap: true    // For touch device
  }
});

// Those are handler for links, since a click open an href automatically
// You can set the href open on double click (dblclick event) instead.
//
// NOTE that StackOverFlow prevents a window open in the snippet sandbox...
//      But it works. ;)
$("a.coolLink, a#eoi").click(function(e){
  e.preventDefault();
});
$("a.coolLink, a#eoi").on("dblclick",function(e){
  e.preventDefault();
  window.open($(this).attr("href"));
});

一定要包含jQuery库,ToolTipster bundle 库 你可以找到所有here。或here

答案 1 :(得分:0)

初始化工具提示时,尝试使用trigger值:

trigger: ('ontouchstart' in window) ? 'click' : 'hover'
相关问题