Skip to content

Instantly share code, notes, and snippets.

View jimyuan's full-sized avatar

Jim jimyuan

  • Home
  • sh.cn
View GitHub Profile
@jimyuan
jimyuan / inView.js
Created July 5, 2018 06:33
Object in viewport
var top = obj.getBoundingClientRect().top //元素顶端到可见区域顶端的距离
var se = document.documentElement.clientHeight //浏览器可见区域高度。
if(top <= se ) {
//code
}
@jimyuan
jimyuan / css
Created September 8, 2017 05:42
在页面滚动时禁用 :hover 样式
.disable-hover {
pointer-events: none;
}
@jimyuan
jimyuan / _mixins.scss
Last active August 29, 2015 14:21
useful sass mixins
// A simple mixin to give dimensions to a box.
@mixin box($width, $height: $width) {
width: $width;
height: $height;
}
// clearfix
@mixin clearfix {
&:after {
content: "";
@jimyuan
jimyuan / convert-unit.scss
Created May 14, 2015 01:42
A unit convert function for scss
/// Convert one unit into another
/// @author Hugo Giraudel
/// @param {Number} $value - Initial value
/// @param {String} $unit - Desired unit
/// @return {Number}
/// @throw Error if `$unit` does not exist or if units are incompatible.
@function convert-unit($value, $unit) {
  $units: (
    'px': 0px,
    'cm': 0cm,
@jimyuan
jimyuan / sprite.scss
Last active August 29, 2015 14:15
compass css sprite for x or 2x background image
//----------------------------------------------------//
// compass css sprite for x or 2x or 3x background image
//----------------------------------------------------//
$sprites-spacing: 5px;
@import "icons/*.png"; // got a variable named $icons-sprites
// @import "icons-2x/*.png"; // got a variable named $icons-2x-sprites
// @import "icons-3x/*.png"; // got a variable named $icons-3x-sprites
@mixin get-sprite( $map, $sprite, $x: 1, $adjustX: 0, $adjustY: 0, $positionAdjustY: 0, $repeat: no-repeat ) {