Skip to content

Instantly share code, notes, and snippets.

// atomBackup
@thinkgarden
thinkgarden / mvvm.js
Last active May 23, 2018 05:34
[mvvm] A simple code for mvvm framework #js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>forvue</title>
</head>
<body>
<div id="app">
<input type="text" v-model="text"> <br>
{{ text }} <br>
function arrayToCSV (twoDiArray) {
// Modified from: http://stackoverflow.com/questions/17836273/
// export-javascript-data-to-csv-file-without-server-interaction
var csvRows = [];
// for (var i = 0; i < twoDiArray.length; ++i) {
// for (var j = 0; j < twoDiArray[i].length; ++j) {
// console.log(twoDiArray[i][j])
// temp[i][j] = '\"' + `${dateFns.format(twoDiArray[i][j].timestamp,'HH:mm:ss')}` + '\"'; // Handle elements that contain comma
// }
// csvRows.push(temp[i].join(','));
@thinkgarden
thinkgarden / parallax.js
Last active May 23, 2018 05:35
[parallax] A simple parallax animation plugin for jQuery #mobile #parallax #js
!function($) {
var startPos, // 开始触摸点(X/Y坐标)
endPos,
stage, // 用于标识 onStart/onMove/onEnd 流程的第几阶段,解决 onEnd 重复调用
offset, // 偏移距离
direction, // 翻页方向
curPage, // page 当前页
pageCount, // page 数量
pageWidth, // page 宽度
@thinkgarden
thinkgarden / utils.js
Last active November 29, 2018 09:38
[js functions] useful function for js #js
// /userinfo/2144/id => ['/userinfo','/useinfo/2144,'/userindo/2144/id']
export function urlToList(url) {
const urllist = url.split('/').filter(i => i);
return urllist.map((urlItem, index) => {
return `/${urllist.slice(0, index + 1).join('/')}`;
});
}
// 极坐标转换成笛卡尔坐标
@thinkgarden
thinkgarden / es6.js
Created May 23, 2018 06:24
[js extend] basic js extend method
class Widget {
constructor(width, height, label) {
this.width = width || 50;
this.height = height || 50;
this.$elem = null;
}
render($where){
if(this.$elem) {
this.$elem.css({
@thinkgarden
thinkgarden / generate.js
Last active July 8, 2018 04:00
[generate] some sample for generate
function *foo() {
var x = yield 2;
z++;
var y = yield (x * z);
console.log( x, y, z );
}
var z = 1;
var it1 = foo();
var it2 = foo();
@thinkgarden
thinkgarden / iphoneX.md
Last active June 14, 2018 01:32
[iphoneX.css]

搜索关键词 iphone X fixed bottom

第一步:设置网页在可视窗口的布局方式

  • 新增 viewport-fit 属性,使得页面内容完全覆盖整个窗口:
<meta name="viewport" content="width=device-width, viewport-fit=cover">
@thinkgarden
thinkgarden / RNStings.md
Created June 15, 2018 02:20
[React Native Settings] The Basic settings of React Native

React Native Settings

Init a Project

$ react-native init --help
Usage: react-native init <ProjectName> [--verbose]
Eg: react-native init --version="0.36.0" MyNewApp
@thinkgarden
thinkgarden / saga.html
Created July 8, 2018 04:07
[little saga] some concept for saga
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"></meta>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
></meta>