Skip to content

Instantly share code, notes, and snippets.

View mogewcy's full-sized avatar

浴火小青春 mogewcy

View GitHub Profile
@mogewcy
mogewcy / index.html
Last active April 17, 2020 01:58
JS Bin// source https://jsbin.com/geyofap js 实现环形加载条
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.circle_process{
position: relative;
width: 200px;
@mogewcy
mogewcy / javascript
Created May 16, 2018 03:29
mini vuex
// 来源: https://smallpath.me/post/blog-vuex-wheel
const global = typeof window !== 'undefined' ? window : process
class Store {
constructor({
state,
actions,
mutations,
getters
}) {
<div class="loading">
<div>
<div class="circle">
</div>
</div>
</div>
.loading{
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
div{
border:1px solid red;
width: 30px;
@mogewcy
mogewcy / matchesSelector
Created February 23, 2017 13:00
匹配元素和选择器
function matchesSelector(el, selector) {
var p = Element.prototype;
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function(s) {
return [].indexOf.call(document.querySelectorAll(s), this) !== -1;
};
return f.call(el, selector);
}
// 用法
matchesSelector(document.getElementById('myDiv'), 'div.someSelector[some-attribute=true]')
@mogewcy
mogewcy / Gulpfile.js
Created December 1, 2016 03:30 — forked from 0x1ad2/Gulpfile.js
My gulpfile example for How to enhance your front-end development workflow using Gulp
/*
* 0x1ad2 base Gulp.js file
* https://twitter.com/0x1ad2
*/
/*
* Define plugins
*/
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
@mogewcy
mogewcy / hexToRgb.js
Created September 25, 2016 02:13
16进制转rgb
// 来源 http://laker.me/blog/2015/10/10/15_1010_rgb_hex_color/
var hexToRgb = function(hex) {
var rgb = [];
hex = hex.substr(1);//去除前缀 # 号
if (hex.length === 3) { // 处理 "#abc" 成 "#aabbcc"
hex = hex.replace(/(.)/g, '$1$1');
}
@mogewcy
mogewcy / bitcolor.js
Created September 25, 2016 01:57 — forked from lrvick/bitcolor.js
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@mogewcy
mogewcy / rgbToHex.js
Created September 25, 2016 01:30
rgb 转换16进制
// 来源 http://laker.me/blog/2015/10/10/15_1010_rgb_hex_color/
var rgbToHex = function(rgb) {
// rgb(x, y, z)
var color = rgb.toString().match(/\d+/g); // 把 x,y,z 推送到 color 数组里
var hex = "#";
for (var i = 0; i < 3; i++) {
// 'Number.toString(16)' 是JS默认能实现转换成16进制数的方法.
// 'color[i]' 是数组,要转换成字符串.
// 如果结果是一位数,就在前面补零。例如: A变成0A