LoginSignup
5
4

More than 3 years have passed since last update.

jquery.ui.touch-punch.jsをSurfaceのタッチパネルでも使えるようにする

Posted at

概要

jQuery UIをタッチイベントに対応させるライブラリに
jquery.ui.touch-punch.jsがあるが、
surfaceのタッチイベントでは動かないので
jquery.ui.touch-punch.jsを修正する。

施策

  $.support.touch = 'ontouchend' in document;

上記スクリプトの下に追加

  $.support.touch = 'ontouchend' in document;

  //追加
  if('onpointerenter' in window){
    $.support.touch = true;
  }

解説

「Ignore browsers without touch support」の行で
タッチデバイス以外は処理を中断するスクリプトが記述されているため、
ポインタデバイスであるsurfaceでは動かなくなる。

  // Detect touch support
  $.support.touch = 'ontouchend' in document;

  if('onpointerenter' in window){
    $.support.touch = true;
  }

    // Ignore browsers without touch support
  if (!$.support.touch) {
    return;
  }
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4