-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ isInViewport_*.js | |
/**/*.dmp | ||
TAGS | ||
/**/*.tern-port | ||
node_modules | ||
*compiled* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title> | ||
ES6/ES2015 module isInViewport Example | ||
</title> | ||
<link rel="stylesheet" href="./common.css" /> | ||
<style> | ||
.box { | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
-ms-box-sizing: border-box; | ||
box-sizing: border-box; | ||
background-color: #C5C7BC; | ||
height: 501px; | ||
width: 100%; | ||
margin-bottom: 2px; | ||
text-align: center; | ||
} | ||
p { | ||
padding: 0; | ||
margin: 0; | ||
line-height: 1.5em; | ||
position: relative; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
} | ||
.box.last { | ||
color: #C5C7BC; | ||
} | ||
.tolerance { | ||
height: 100px; | ||
width: 100%; | ||
background-color: rgb(212, 12, 20); | ||
background-color: rgba(255, 0, 0, 0.4); | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 1; | ||
} | ||
.tolerance:before, .tolerance:after { | ||
content:""; | ||
display: table; | ||
} | ||
.tolerance:after { | ||
clear: both; | ||
} | ||
.tolerance { | ||
zoom: 1; | ||
/* For IE 6/7 (trigger hasLayout) */ | ||
} | ||
.tolerance * { | ||
padding: 36px; | ||
color: #fff; | ||
} | ||
</style> | ||
<script src="./advanced.compiled.js"> | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<div class="tolerance"> | ||
<a class="right">Tolerance Area (Tolerance = 100px)</a> | ||
</div> | ||
<div id="container"> | ||
<div class="box"> | ||
<p> | ||
1 | ||
</p> | ||
</div> | ||
<div class="box"> | ||
<p> | ||
2 | ||
</p> | ||
</div> | ||
<div class="box"> | ||
<p> | ||
3 | ||
</p> | ||
</div> | ||
<div class="box"> | ||
<p> | ||
4 | ||
</p> | ||
</div> | ||
<div class="box"> | ||
<p> | ||
5 | ||
</p> | ||
</div> | ||
<div class="box"> | ||
<p> | ||
6 | ||
</p> | ||
</div> | ||
<div class="box last"> | ||
<p> | ||
This div, if not in the tolerance area, will never turn light grey. | ||
</p> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import $ from 'jquery' | ||
import 'is-in-viewport' | ||
|
||
|
||
$(document).ready(function() { | ||
$('#container > div.box').css('background-color', '#21221E') | ||
$('#container > div.box:in-viewport(100)').css('background-color', '#C5C7BC') | ||
|
||
$(window).scroll(function() { | ||
$('#container > div.box').css('background-color', '#21221E') | ||
$('#container > div.box:in-viewport(100)').css('background-color', '#C5C7BC') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background-color: #FBFBFB; | ||
color: #151612; | ||
font-family:"Century Gothic", CenturyGothic, AppleGothic, sans-serif; | ||
} | ||
h1 { | ||
font-size: 3em; | ||
} | ||
a, a:visited, a:active, a:hover { | ||
text-decoration: none; | ||
} | ||
.left { | ||
float: left; | ||
} | ||
.right { | ||
float: right; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "is-in-viewport-es6-example", | ||
"version": "1.0.0", | ||
"description": "An example of using is-in-viewport in an es6 module", | ||
"main": "advanced.compiled.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rollup -c", | ||
"prepublish": "rollup -c" | ||
}, | ||
"author": "Mudit Ameta", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"rollup": "^0.41.5", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-node-resolve": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"jquery": "^3.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Using `is-in-viewport` in an ES6/ES2015 module | ||
----- | ||
|
||
Run `npm install` in this folder and then serve it. | ||
Navigate to `advanced.html` and you shall the plugin loaded up. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import nodeResolve from 'rollup-plugin-node-resolve' | ||
|
||
export default { | ||
entry: './advanced.js', | ||
dest: './advanced.compiled.js', | ||
format: 'iife', | ||
globals: { | ||
window: 'window' | ||
}, | ||
external: ['window'], | ||
plugins: [nodeResolve({ skip: ['window'] }), commonjs({ exclude: ['window'] })] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters