Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

曾浩 think2011

🏠
Working from home
View GitHub Profile
View 合并和排序.js
var a = [1, 2, 45, 88];
var b = [3, 7, 8];
var flag = 0;
for (let i = 0; i < b.length; i++) {
if (b[i] <= a[flag] || flag > a.length) {
a.splice(flag, 0, b[i]);
} else {
i--;
View AirScroll.js
export default class AirScroll {
constructor(options, updateCb) {
this.container = options.container
this.itemHeight = options.itemHeight
this.containerHeight = options.containerHeight
this.sourceItems = options.items
this.items = []
this.updateCb = updateCb
this.init()
View ng-virual-list.js
angular.module('virtualListApp')
.directive('uiVirtualList',
[function () {
'use strict';
return {
restrict: 'E',
require: "ngModel",
templateUrl: "views/directives/ui-virtual-list.html",
scope: {
uiDataProvider: '=',
View outerClick.js
function outerClick(selector, fn) {
$(document).on("click", function (event) {
var isHit = $(event.target).closest(selector).length
if (!isHit) fn.call(fn, event)
})
return function () {
$(document).off('click', fn)
}
View stats.js
/* stats.js - http://github.com/mrdoob/stats.js*/
var Stats = function () {
var l = Date.now(), m = l, g = 0, n = Infinity, o = 0, h = 0, p = Infinity, q = 0, r = 0, s = 0, f = document.createElement("div");
f.id = "stats";
f.addEventListener("mousedown", function (b) {
b.preventDefault();
t(++s % 2)
}, !1);
f.style.cssText = "width:80px;opacity:0.9;cursor:pointer";
var a = document.createElement("div");
@think2011
think2011 / scene.scss
Last active Nov 13, 2016
css实现的tabs
View scene.scss
[class^=scene-] {
transform: translate3d(0, 0, 0);
transition: .3s ease;
display: flex;
flex-flow: row nowrap;
@for $i from 0 through 5 {
&.scene-#{$i} {
transform: translate3d(#{-($i * 100%)}, 0, 0);
}
View dial2.html
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="demo.css">
<!--<script src="index.js"></script>-->
</head>
<style>
@think2011
think2011 / dial.html
Last active Oct 31, 2016
canvass dial
View dial.html
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="demo.css">
<!--<script src="index.js"></script>-->
</head>
<style>
View marquee.js
$.fn.marquee = function (options) {
var $that = this
var that = this[0]
if (!that) return
options = $.extend({}, {
speed: 50
}, options)
var timer = setInterval(marquee, options.speed)
@think2011
think2011 / Checker.js
Last active Nov 6, 2016
checker 选择反选
View Checker.js
class Checker {
/**
* 生成一个 checker
* @param context 是一个object,跟itemKey配合得到items
* @param itemKey context中的items的key
* @param idKey 用于匹配的值
* @example
this.checker = new Checker({
context: this,
itemKey: 'items',