Skip to content

Instantly share code, notes, and snippets.

@7cc
7cc / getScrollTopMax.js
Created June 14, 2013 02:38
scrollTopMax
/**
getScrollTopMax
@test
https://developer.mozilla.org/ja/docs/DOM/element.clientHeight
*/
var target = document.getElementById("idDiv")
target.scrollHeight // 401
target.clientHeight // 102
target.scrollTopMax // 299
@7cc
7cc / easing.js
Last active December 18, 2015 16:38
easing, tween
/**
* easing
* @param t current time
* @parm d duartion (total time)
* @return 0 - 1
*/
/*
weeker
Sine
@7cc
7cc / select_pre.js
Created July 3, 2013 17:55
for MDN
/*
make btn#selectPre
click -> select pre-content
remake - if webkit support mouseenter
*/
;(function(d){
if(!window.getSelection){
return
@7cc
7cc / index.html
Last active April 4, 2019 11:47
no dot for links, input, button
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>remove dot</title>
<link rel="stylesheet" href="no-dot.css" type="text/css" />
</head>
@7cc
7cc / body-scroll-in-Standards.html
Created September 11, 2013 08:24
window.pageYOffset always returns 0 in some CSS
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>body scroll in Standards Mode</title>
<style>
html{
height: 100%;
overflow: hidden;
}
// ==UserScript==
// @name Save Indent - Better Copy for Github, Gist, google-code-prettify
// @namespace https://gist.github.com/7cc
// @description save indent/whitespace when copy source code / コピーした際のインデントを正常化する
// @include *
// @exclued https://www.google*
// @exclued https://www.youtube.com/*
// @version 2.03
// @grant none
// ==/UserScript==
@7cc
7cc / editToReload.js
Created November 20, 2013 20:06
reload if edit
!function(){
// http://javascripter.hatenablog.com/entry/20081103/1225682273
var last
(function check(){
var xhr = new XMLHttpRequest
var url = location.href
xhr.open("GET", url, true)
xhr.onload = function(){
if ( !last || last === xhr.response ) {
[draggable=true]{
position: absolute;
top: 50px;
cursor: move;
box-shadow: 4px 0px 12px;
padding: .25em .5em
}
@7cc
7cc / bug.md
Created January 8, 2014 23:54
history ongo, onback

bug: firefox

history.state dissapears in FF

var hash = "#foo"

  1. pushState(1, null, hash)
  2. click internal link <a href="foo">
  3. hisotory.state losts in FF

difference

$(sel).offset().top // jQuery
el.getBoundingClientRect().top + pageYOffset - document.documentElement.clientTop // pure JS

document.documentElement.clientTop?