Skip to content

Instantly share code, notes, and snippets.

View roatnek's full-sized avatar

Kentaro Tanaka roatnek

View GitHub Profile
@roatnek
roatnek / scrollDocument.js
Last active March 13, 2017 07:07
No more `$('html, body').animate()`
var scrolling_elem = document.scrollingElement;
$(scrolling_elem)
.filter(':not(:animated)')
.animate({scrollTop: 0}, {duration: 500, easing: 'swing'});
var isIE = !(window.ActiveXObject) && "ActiveXObject" in window;
@roatnek
roatnek / uncheckCheckboxWhenItWasChecked.js
Last active March 13, 2017 07:26
チェックしたチェックボックスをアンチェックする
var checkbox = document.querySelector('input[type="checkbox"]');
checkbox.addEventListener('click', function(event) {
event.target.checked = false;
});
var original_array = ['D-1', 'D-2', 'D-3'];
var copied_array = original_array.concat();
original_array.push('Dragoon');
// original_array --> ['D-1', 'D-2', 'D-3', 'Dragoon']
// copied_array --> ['D-1', 'D-2', 'D-3']
@mixin pseudo-elem-icon($width, $height, $image) {
content: "";
width: $width;
height: $height;
display: inline-block;
background: url($image) no-repeat 0 0;
background-size: contain;
}
// Usage

タイトルで出オチ。

説明

visibility:hiddenしたフォームコントロールはタブフォーカスできない(タブオーダーから外れる)ことに気が付きました。

display:noneしたフォームコントロールがタブフォーカスできないのは知っていたし理解できるけど、visibility

  • 見えてるか見えてないか」の表示性を表すプロパティであり、
  • displayのように存在までなくしてしまうわけではない
@roatnek
roatnek / disablePhoneLink.js
Last active April 13, 2017 00:36
telな機能を持たないデバイスではtelリンクを無効化する
// Node.js
var fs = require('fs');
function func() {
try {
fs.statSync('./foo/');
// operate files in the directory foo