This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(mdDialog): added openFrom and closeTo properties #5075
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,30 @@ | ||
<div ng-controller="AppCtrl" layout="row" ng-cloak style="height: 300px"> | ||
<div layout="column" layout-align="center center" | ||
style="background-color: #f2f2f2" class="md-padding"> | ||
<span id="left">left</span> | ||
</div> | ||
<div layout="column" layout-align="center"> | ||
<p class="inset"> | ||
A dialog can specify its origin and target with <code>openFrom</code> and | ||
<code>closeTo</code> properties. | ||
|
||
The options showFrom and closeTo can be specified as a string [where internally | ||
querySelector( ) is used to perform the DOM element lookup], | ||
element or an Rect object [with top, left, width, height fields]. | ||
</p> | ||
|
||
<div class="dialog-demo-content" layout="row" layout-wrap> | ||
<md-button class="md-primary md-raised" ng-click="openFromLeft()" flex flex-md="100"> | ||
Open From Left Close To Right | ||
</md-button> | ||
<md-button class="md-primary md-raised" ng-click="openOffscreen()" flex flex-md="100"> | ||
From Offscreen | ||
</md-button> | ||
</div> | ||
</div> | ||
|
||
<div layout="column" layout-align="center center" | ||
style="background-color: #f2f2f2" class="md-padding"> | ||
<span id="right">right</span> | ||
</div> | ||
</div> |
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,38 @@ | ||
angular.module('dialogDemo2', ['ngMaterial']) | ||
|
||
.controller('AppCtrl', function($scope, $mdDialog) { | ||
$scope.openFromLeft = function() { | ||
$mdDialog.show( | ||
$mdDialog.alert() | ||
.clickOutsideToClose(true) | ||
.title('Opening from the left') | ||
.content('Closing to the right!') | ||
.ariaLabel('Left to right demo') | ||
.ok('Nice!') | ||
// You can specify either sting with query selector | ||
.openFrom('#left') | ||
// or an element | ||
.closeTo(angular.element(document.querySelector('#right'))) | ||
); | ||
}; | ||
|
||
$scope.openOffscreen = function() { | ||
$mdDialog.show( | ||
$mdDialog.alert() | ||
.clickOutsideToClose(true) | ||
.title('Opening from offscreen') | ||
.content('Closing to offscreen') | ||
.ariaLabel('Offscreen Demo') | ||
.ok('Amazing!') | ||
// Or you can specify the rect to do the transition from | ||
.openFrom({ | ||
top: -50, | ||
width: 30, | ||
height: 80 | ||
}) | ||
.closeTo({ | ||
left: 1500 | ||
}) | ||
); | ||
}; | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,12 +87,13 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) { | |
*/ | ||
calculateZoomToOrigin: function (element, originator) { | ||
var origin = originator.element; | ||
var bounds = originator.bounds; | ||
var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )"; | ||
var buildZoom = angular.bind(null, $mdUtil.supplant, zoomTemplate); | ||
var zoomStyle = buildZoom({centerX: 0, centerY: 0, scaleX: 0.5, scaleY: 0.5}); | ||
|
||
if (origin) { | ||
var originBnds = self.clientRect(origin) || self.copyRect(originator.bounds); | ||
if (origin || bounds) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
var originBnds = origin ? self.clientRect(origin) : self.copyRect(bounds); | ||
var dialogRect = self.copyRect(element[0].getBoundingClientRect()); | ||
var dialogCenterPt = self.centerPointFor(dialogRect); | ||
var originCenterPt = self.centerPointFor(originBnds); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very confusing to read... I think a refactoring is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix.