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

Commit

Permalink
slightly improve sizing when using transforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 9, 2014
1 parent e963728 commit 3b08d4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
11 changes: 8 additions & 3 deletions core-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@
this._shouldPosition = {top: t, left: l};
}

// TODO(sorvell): need to work out interaction between sizing
// and positioning
this.sizeTarget();
this.positionTarget();
}
},

// TODO(sorvell): getBoundingClientRect may give dubious info due to
// transform.
sizeTarget: function() {
var sizer = this.sizingTarget || this.target;
var rect = sizer.getBoundingClientRect();
Expand All @@ -293,13 +297,14 @@

positionTarget: function() {
// vertically and horizontally center if not positioned
var rect = this.target.getBoundingClientRect();
if (this._shouldPosition.top) {
var t = Math.max((window.innerHeight - rect.height) / 2, 0);
var t = Math.max((window.innerHeight -
this.target.offsetHeight) / 2, 0);
this.target.style.top = t + 'px';
}
if (this._shouldPosition.left) {
var l = Math.max((window.innerWidth - rect.width) / 2, 0);
var l = Math.max((window.innerWidth -
this.target.offsetWidth) / 2, 0);
this.target.style.left = l + 'px';
}
},
Expand Down
23 changes: 15 additions & 8 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>core-overlay</title>
<link rel="import" href="core-overlay.html">
<script src="../platform/platform.js"></script>
<link rel="import" href="core-overlay.html">
<style>
.dialog {
box-sizing: border-box;
Expand All @@ -20,10 +20,20 @@
}

#dialog {
top: 72px;
left: 50%;
/*top: 72px;
left: 10px;
margin-left: -256px;*/
width: 512px;
margin-left: -256px;

}

#dialog.core-revealed {
transition: all 0.3s ease-in;
-webkit-transform: scale(0.1) translateY(-500px);
}

#dialog.core-overlay.core-opened {
-webkit-transform: none;
}

#confirmation.core-opened {
Expand Down Expand Up @@ -51,6 +61,7 @@
<h2>Dialog</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fringilla sapien sed enim sollicitudin laoreet. Suspendisse suscipit, metus ac volutpat sodales, libero magna semper lacus, molestie fringilla massa orci ut arcu. Nullam sodales urna sit amet odio vehicula mattis.</div><br><br>
<div>Ut aliquam vulputate congue. Vestibulum pretium pretium nulla quis sollicitudin. Praesent lacinia congue erat nec mattis. Fusce commodo lacus est. Duis turpis eros, ultrices sed aliquet non, blandit egestas velit. Integer a augue nec lorem tristique hendrerit. Curabitur imperdiet risus id enim bibendum vestibulum. Integer id magna at arcu faucibus fermentum vel a augue. Sed fringilla venenatis dolor, in blandit magna molestie luctus. Vestibulum dignissim posuere ultrices. Aenean urna nisl, tincidunt vitae iaculis ut, pharetra nec eros.</div><br><br>

<div>
<input placeholder="say something..." autofocus oninput="somethingCheck(this)"></input><br>
I agree with this wholeheartedly.
Expand All @@ -74,10 +85,6 @@ <h2>Dialog</h2>
<template>
<style>

:host(.core-overlay) {
transition: opacity 0.3s ease-in;
}

:host {
box-sizing: border-box;
-moz-box-sizing: border-box;
Expand Down

0 comments on commit 3b08d4c

Please sign in to comment.