Skip to content

Instantly share code, notes, and snippets.

View lynxerzhang's full-sized avatar
🤒

frankwinter lynxerzhang

🤒
  • geckostudio
  • shanghai
View GitHub Profile
@lynxerzhang
lynxerzhang / gist:741c17ba53796d845a478f5ca576350b
Created January 12, 2021 07:22 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
@lynxerzhang
lynxerzhang / checkAryisEqual.js
Created May 13, 2020 05:52
js check if two arrays are equal or not
//es6
const checkAryisEqual = (aryA, aryB) => JSON.stringify(aryA) == "[" + aryB.toString() + "]";
//es5
function checkAryisEqual(aryA, aryB) {
return JSON.stringify(aryA) === "[" + aryB.toString() + "]";
}
@lynxerzhang
lynxerzhang / JS_LocalStorage.as
Last active August 16, 2019 08:04
calling anonymous js (不需要额外书写js)
package utils
{
import flash.external.ExternalInterface;
//@see https://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370
public class JS_LocalStorage
{
public function JS_LocalStorage()
{
}
@lynxerzhang
lynxerzhang / StageMatchContent.jsfl
Last active April 24, 2019 03:28
set Flash IDE's stage to match content's size(设置舞台的长宽以匹配舞台中放置的mc元件)
//@see http://keith-hair.net/blog/2010/03/21/resizing-flash-documents-to-fit-contents-in-jsfl/
//@see http://stackoverflow.com/questions/8056990/how-does-one-get-the-stroked-bounds-of-a-symbol-in-jsfl
var doc = fl.getDocumentDOM();
var timeline = doc.getTimeline();
var layer = null;
var frame = null;
var element = null;
run();
@lynxerzhang
lynxerzhang / consoleUtil.js
Last active June 12, 2017 09:12
console.log and console.warn's Polyfill
//@see https://www.paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
//inspired from paulirish's console.log function
!(function(win, funNameAry, titleAry, max){
max = max || 100;
for(var i = 0, funName = ""; i < funNameAry.length, funName = funNameAry[i]; i ++){
win[funName] = (function(i, n){
return function(){
this[n].history = this[n].history || [];
this[n].logMax = this[n].logMax || max;
this[n].history.push(arguments);
@lynxerzhang
lynxerzhang / ReactCreatColorPanel.css
Created May 31, 2017 06:02
React.js create a like flash's color plate feature
*{
box-sizing: border-box;
}
.blockBorder{
border: 1px solid #000;
}
@lynxerzhang
lynxerzhang / ByteArray.js
Created May 25, 2017 08:50
encapsulate js ArrayBuffer class and DataView class
//在构造函数中创建了一个DataView对象和一个position变量追踪当前指针指向哪个字节。
class ByteArray extends ArrayBuffer
{
constructor(...args) {
super(...args);
this.dataView = new DataView(this);
this.position = 0;
}
get length(){
@lynxerzhang
lynxerzhang / index.html
Created March 31, 2017 12:45
Simple HTML5 Motion
<canvas id ="canvas" width="300", height="200"></canvas>
//
// StringExt.swift
//
// some useful swift string's extension
//
// Xcode version is 7.3, swift version is 2.2
//
// TODO
//
//