-
Notifications
You must be signed in to change notification settings - Fork 3
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
11 changed files
with
694 additions
and
233 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = function( grunt ) { | ||
|
||
/* Configure */ | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON( 'package.json' ), | ||
|
||
uglify: { | ||
options: { | ||
report: 'gzip', // requires using `grunt --verbose` | ||
compress: true, | ||
preserveComments: 'some' | ||
}, | ||
dist: { | ||
files: { | ||
'viewport.min.js': [ 'viewport.js' ] | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks( 'grunt-contrib-uglify' ); | ||
|
||
grunt.registerTask( 'default', [ | ||
'uglify' | ||
]); | ||
}; |
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,70 @@ | ||
var logger = function() { | ||
|
||
var results | ||
, msg | ||
; | ||
|
||
if ( console && console.log ) { | ||
return console.log( '=> ', arguments ); | ||
} | ||
|
||
// IE7 logging | ||
results = document.getElementById( 'breakpoints' ); | ||
msg = '<p>' + Array.prototype.slice.call( arguments ).join( ', ' ) + '</p>'; | ||
|
||
results.innerHTML = results.innerHTML + msg; | ||
} | ||
|
||
var handler = function( isCurrent, vp ) { | ||
|
||
logger( vp.name, isCurrent ); | ||
}; | ||
|
||
var myVPOne = viewport([ | ||
{ | ||
name: 'small', | ||
width: [ 0, 480 ] | ||
}, | ||
{ | ||
name: 'medium', | ||
width: [ 481, 768 ] | ||
}, | ||
{ | ||
name: 'large', | ||
width: [ 769 ] | ||
} | ||
]); | ||
|
||
var myVPOneAll = myVPOne.subscribe( '*', function( vpPresent, vpPrevious ) { | ||
logger( 'viewport dimensions: ' + myVPOne.size.width + ' x ' + myVPOne.size.height ); | ||
logger( 'name: *', 'present: ' + vpPresent.name, 'previous: ' + vpPrevious.name ); | ||
}); | ||
var myVPOne1 = myVPOne.subscribe( 'small', function( isCurrent, vp ) { | ||
|
||
logger( vp.name, isCurrent ); | ||
|
||
if ( isNaN( myVPOne1 ) ) return; | ||
|
||
myVPOne.unsubscribe( myVPOne1 ); | ||
}); | ||
var myVPOne2 = myVPOne.subscribe( 'medium', handler ); | ||
var myVPOne3 = myVPOne.subscribe( 'large', handler ); | ||
|
||
var myVPTwo = viewport([ | ||
{ | ||
name: 'small-one', | ||
width: [ 320 ] | ||
}, | ||
{ | ||
name: 'medium-one', | ||
width: [ 1250 ] | ||
}, | ||
{ | ||
name: 'height-one', | ||
width: [ 600 ], | ||
height: [ 600 ] | ||
} | ||
]); | ||
var myVPTwo1 = myVPTwo.subscribe( 'small-one', handler ); | ||
var myVPTwo2 = myVPTwo.subscribe( 'medium-one', handler ); | ||
var myVPTwo3 = myVPTwo.subscribe( 'height-one', handler ); |
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,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | ||
<title>Viewport Tests</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<style type="text/css"> | ||
#window { | ||
margin:0; | ||
} | ||
.result { | ||
padding:10px; | ||
background:#ccc; | ||
} | ||
.break { | ||
background:red; | ||
} | ||
|
||
@media screen and (max-width: 480px) { | ||
#break-max-480 { | ||
background:green; | ||
} | ||
} | ||
@media screen and (max-width: 768px) { | ||
#break-max-768 { | ||
background:green; | ||
} | ||
} | ||
@media screen and (min-width: 769px) { | ||
#break-min-769 { | ||
background:green; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 320px) { | ||
#break-min-320 { | ||
background:green; | ||
} | ||
} | ||
@media screen and (min-width: 1250px) { | ||
#break-min-1250 { | ||
background:green; | ||
} | ||
} | ||
@media screen and (min-height: 600px) and ( min-width: 600px ) { | ||
#break-min-600 { | ||
background:green; | ||
} | ||
} | ||
|
||
</style> | ||
</head> | ||
<body id="feature-tests"> | ||
|
||
<div class="viewport" id="window"> | ||
|
||
<h1>Viewport Tests</h1> | ||
|
||
<div class="test" id="breakpoints"> | ||
|
||
<p class="result break" id="break-max-480">small <code>(max-width:480px)</code></p> | ||
<p class="result break" id="break-max-768">medium <code>(max-width:768px)</code></p> | ||
<p class="result break" id="break-min-769">large <code>(min-width:769px)</code></p> | ||
|
||
<p class="result break" id="break-min-320">small-one <code>(min-width:320px)</code></p> | ||
<p class="result break" id="break-min-1250">medium-one <code>(min-width:1250px)</code></p> | ||
<p class="result break" id="break-min-600">height-one <code>(min-height:600px)</code></p> | ||
|
||
</div> | ||
|
||
</div> | ||
<script src="../viewport.js"></script> | ||
<script src="demo.js"></script> | ||
</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
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
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
Oops, something went wrong.