Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FaaPz committed Jun 17, 2014
1 parent 9371e09 commit 2d825dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
midway
======
# midway

simplified responsive elements centering

*Originally inspired by [Brandon Jacoby](https://github.com/BrandonJacoby/Midway.js)*

*Rewritten natively by [Fabian de Laender](https://github.com/FaaPz/midway)*

### Usage

``` html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>midway example</title>
<script type="text/javascript" src="midway.min.js"></script>
</head>
<body>
<div class="midway-horizontal midway-vertical"></div>
</body>
</html>
```

### Changelog

##### v1.0.1
- Minor changes

##### v1.0.0
- First version
13 changes: 7 additions & 6 deletions midway.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
/* midway - simplified responsive elements centering v1.0.0
/* midway - simplified responsive elements centering v1.0.1
* Crafted in Finland by a Dutchman called Fabian de Laender
* Copyright (c) 2014 Fabian de Laender; Licensed MIT
*/
function _initMidway() {
'use strict';

var centerHorizontal = document.querySelectorAll('.midway-horizontal'),
centerVertical = document.querySelectorAll('.midway-vertical');
centerVertical = document.querySelectorAll('.midway-vertical'),
i = 0;

for( var i = 0; i < centerHorizontal.length; i++ ) {
for( i = 0; i < centerHorizontal.length; i++ ) {
centerHorizontal[i].style.marginLeft = -centerHorizontal[i].offsetWidth / 2 + 'px';
centerHorizontal[i].style.display = 'inline';
centerHorizontal[i].style.position = 'absolute';
centerHorizontal[i].style.left = '50%';
}

for( var i = 0; i < centerVertical.length; i++ ) {
for( i = 0; i < centerVertical.length; i++ ) {
centerVertical[i].style.marginTop = -centerVertical[i].offsetWidth / 2 + 'px';
centerVertical[i].style.display = 'inline';
centerVertical[i].style.position = 'absolute';
Expand All @@ -25,8 +26,8 @@ function _initMidway() {

window.onload = function() {
_initMidway();
}
};

window.onresize = function() {
_initMidway();
}
};
4 changes: 2 additions & 2 deletions midway.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2d825dc

Please sign in to comment.