Skip to content

Commit

Permalink
Merge pull request shipshapecode#208 from HubSpot/round-position-on-n…
Browse files Browse the repository at this point in the history
…on-retina

Round position on non-retina displays
  • Loading branch information
TrevorBurnham authored Sep 1, 2016
2 parents 3e1e07b + f37e3cd commit 315e9ce
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.3.5",
"version": "1.3.6",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tether",
"repo": "HubSpot/tether",
"version": "1.3.5",
"version": "1.3.6",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <[email protected]>",
Expand Down
11 changes: 10 additions & 1 deletion dist/js/tether.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! tether 1.3.5 */
/*! tether 1.3.6 */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -1181,6 +1181,15 @@ var TetherClass = (function (_Evented) {
xPos = -_pos.right;
}

if (window.matchMedia) {
// HubSpot/tether#207
var retina = window.matchMedia('only screen and (min-resolution: 1.3dppx)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3)').matches;
if (!retina) {
xPos = Math.round(xPos);
yPos = Math.round(yPos);
}
}

css[transformKey] = 'translateX(' + xPos + 'px) translateY(' + yPos + 'px)';

if (transformKey !== 'msTransform') {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tether.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.3.5",
"version": "1.3.6",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <[email protected]>",
Expand Down
10 changes: 10 additions & 0 deletions src/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,16 @@ class TetherClass extends Evented {
xPos = -_pos.right;
}

if (window.matchMedia) {
// HubSpot/tether#207
const retina = window.matchMedia('only screen and (min-resolution: 1.3dppx)').matches ||
window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3)').matches;
if (!retina) {
xPos = Math.round(xPos);
yPos = Math.round(yPos);
}
}

css[transformKey] = `translateX(${ xPos }px) translateY(${ yPos }px)`;

if (transformKey !== 'msTransform') {
Expand Down

0 comments on commit 315e9ce

Please sign in to comment.