Skip to content

Instantly share code, notes, and snippets.

View HelKyle's full-sized avatar
🎯
Focusing

HelKyle HelKyle

🎯
Focusing
View GitHub Profile
@HelKyle
HelKyle / rem.js
Created May 16, 2016 14:40 — forked from fwon/rem.js
/*
* rem.js
* v0.1.1
* fixed 2015-3-12
*/
(function (win){
var doc = win.document,
html = doc.documentElement,
option = html.getAttribute('data-use-rem');
@HelKyle
HelKyle / main.js
Created December 1, 2015 03:33
Flexbox Based Responsive Equal Height Blocks With JavaScript Fallback
;( function( $, window, document, undefined ) {
'use strict';
var s = document.body || document.documentElement, s = s.style;
if ( s.webkitFlexWrap == '' || s.msFlexWrap == '' || s.flexWrap == '' ) return true;
var $list = $( '.list' ),
$items = $list.find( '.list__item__inner' ),
setHeights = function() {
$items.css( 'height', 'auto' );
@HelKyle
HelKyle / vanilla-not-jquery.js
Created November 24, 2015 03:27 — forked from TexRx/vanilla-not-jquery.js
Pure JS alternatives to common CSS class jQuery functions
function hasClass(elem, className) {
return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' ');
}
function addClass(elem, className) {
if (!hasClass(elem, className)) {
elem.className += ' ' + className;
}
}
@HelKyle
HelKyle / datediff.js
Created November 23, 2015 16:36 — forked from remino/datediff.js
JavaScript: DateDiff & DateMeasure: Calculate days, hours, minutes, seconds between two Dates
(function() {
function DateDiff(date1, date2) {
this.days = null;
this.hours = null;
this.minutes = null;
this.seconds = null;
this.date1 = date1;
this.date2 = date2;
@HelKyle
HelKyle / what-forces-layout.md
Created October 14, 2015 06:18 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@HelKyle
HelKyle / javascript_inherit.js
Created October 9, 2015 07:41
JavaScript中的单继承,多继承(都是浅复制)
//单继承,浅复制
var extend = function(target, source) {
for(var property in source) {
traget[property] = source[property];
}
return target;
}
//多继承,属性复制
@HelKyle
HelKyle / trig.scss
Created September 25, 2015 09:24 — forked from kamikat/trig.scss
SCSS/SASS module calculating sin/cos/tan using Taylor Expansion.
///////////////////////////////////////////////////////////
// Plain SASS Trigonometry Algorithm in Taylor Expansion //
// //
// Based on //
// http://japborst.net/posts/sass-sines-and-cosines //
///////////////////////////////////////////////////////////
$pi: 3.14159265359;
$_precision: 10;
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
<div class='box'>
border-radius only
</div>