Skip to content

Instantly share code, notes, and snippets.

View jimyuan's full-sized avatar

Jim jimyuan

  • Home
  • sh.cn
View GitHub Profile
@parkr
parkr / generator_scss.rb
Created June 5, 2012 13:19
Jekyll Plugin to output SCSS without requiring the "---" YAML Front Matter
#
# Jekyll Generator for SCSS
#
# (File paths in this description relative to jekyll project root directory)
# Place this file in ./_plugins
# Place .scss files in ./_scss
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
# Config file placed in ./_sass/config.rb
#
@inter-coder
inter-coder / isInVisiblePartOfScreen.js
Last active August 29, 2015 14:21
One of the ways to find out if element is in the visible part of the screen or not
HTMLElement.prototype.isVisible = function(){
function getPositionTop(element){
var offset = 0;
while(element) {offset += element["offsetTop"];element = element.offsetParent;}
return offset;
}
var posTop = getPositionTop(this);
var posBottom = posTop + this.offsetHeight;
var visibleTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
var visibleBottom = visibleTop + document.body.offsetHeight;