Skip to content

Instantly share code, notes, and snippets.

@tetsunosuke
Last active May 29, 2019 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tetsunosuke/0eab7c293f18d3b3a443165d26f54720 to your computer and use it in GitHub Desktop.
Save tetsunosuke/0eab7c293f18d3b3a443165d26f54720 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/lity/1.6.6/lity.css' />
<script src='https://cdnjs.cloudflare.com/ajax/libs/lity/1.6.6/lity.js'></script>
</head>
<body>
<a href="blank.html" target="_blank">blank</a>
<a href="http://phi-jp.github.io/phiary-workspace/assets/images/cafe.jpg" data-lity>simple</a>
<a href="#">hash</a>
<script>
$(function() {
// ハッシュリンク(#)と別ウィンドウでページを開く場合はスルー
$('a:not([href^="#"],[target="_blank"])').on('click', function(e){
// e.preventDefault(); // ナビゲートをキャンセル...しなくても良いはずです
console.log("data-lityの効果が発動するはず");
});
/**
// ここからは実験のため不要です
$("a").on('click', function(e) {
// e.preventDefault();
console.log("上の行のpreventDefaultがなければ普通に開く");
});
*/
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment