Skip to content

Instantly share code, notes, and snippets.

View crossjs's full-sized avatar
🎯
Focusing

李文富 crossjs

🎯
Focusing
View GitHub Profile
@crossjs
crossjs / gist:9926ae7b46d84f69d538caad57c472d8
Created June 27, 2017 07:21
weiyun make share editable
req_body.is_editable = true
@crossjs
crossjs / ie8-defineproperty.js
Created June 27, 2017 05:12
ie8 Object.defineProperty
<div></div>
<script>
-[1,]||(function(){
var i,o,s=[
"Unknown","UList","Title","TextArea","TableSection",
"TableRow","Table","TableCol","TableCell","TableCaption",
"Style","Span","Select","Script","Param","Paragraph",
"Option","Object","OList","Meta","Marquee","Map","Link",
"Legend","Label","LI","Input","Image","IFrame","Html",
"Heading","Head","HR","FrameSet","Frame","Form","Font",
function props(obj) {
var p = [];
for (; obj != null; obj = Object.getPrototypeOf(obj)) {
var op = Object.getOwnPropertyNames(obj);
for (var i=0; i<op.length; i++)
if (p.indexOf(op[i]) == -1)
p.push(op[i]);
}
return p;
}
var svg = d3.select("body").append("svg").attr("width", 100).attr("height", 100);
var rect = svg.append("rect").attr("x", 40).attr("y", 40).attr("height", 10).attr("width", 10);
rect.on("click", function() {
console.log("rect");
d3.event.stopPropagation();
});
svg.on("click", function() { console.log("svg"); });
@crossjs
crossjs / pagespeed-insights.url
Last active April 23, 2017 15:04
PageSpeed Insights规则
https://developers.google.com/speed/docs/insights/rules?hl=zh-cn
(function(){
var ua = navigator.userAgent.toLowerCase();
var t;
var config = {
/*scheme:必须*/
scheme_IOS: 'sinaweibo://home',
scheme_Adr: 'sinaweibo://splash',
download_url: document.getElementById('J-download-app').value,
timeout: 600
};
(function (canvas) {
var names = ['webgl', 'experimental-webgl', 'webkit-3d', 'moz-webgl']
var context = null;
for (var i = 0; i < names.length; ++i) {
try {
context = canvas.getContext(names[i])
alert(names[i])
} catch (e) {
}
if (context) {
@crossjs
crossjs / gist:0e11d36849db3fbf88fa64b63e121d5f
Created February 14, 2017 10:00
Generate an AUTHORS file based on the output of git shortlog.
#!/usr/bin/env sh
# Generate an AUTHORS file based on the output of git shortlog. It uses ABC
# order, strips out leading spaces and numbers, then filters out specific
# authors.
git shortlog -se \
| perl -spe 's/^\s+\d+\s+//' \
| sed -e '/^CommitSyncScript.*$/d' \
> AUTHORS
@crossjs
crossjs / is360
Created January 25, 2017 09:44
is360
var is360 = function(){
try {
if(/UBrowser/i.test(navigator.userAgent)){
return '';
}
if (typeof window.scrollMaxX !== 'undefined') {
return '';
}
@crossjs
crossjs / what-forces-layout.md
Created December 30, 2016 14:25 — 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()