Comments (10)
Any chance of this making it into next week's release? I see there is a TODO in the current beta. :-)
If not, I can look into adding it as I need to know when resizes occur.
Ideally, it could be configured to output an event continuously as you resize or just when the mouse is released.
from ui-layout.
Yeah I can probably work it in to the mouse release event for the time being. Is there any specific data you'd be looking for to be passed with the event? Or is the event itself enough?
from ui-layout.
Would be great if it could pass along the id of the div that got resized so we can do the right thing based on what was resized.
This would require that the div actually have an id though. This obviously isn't an onerous requirement, but you'd need to handle the case where the div has no id. I guess if it doesn't have an id, then don't fire the event or else fire a "global" resized event with no id.
Short term, I could probably just assume that any "resize" event means everything resized and run any/all code that handles size changes. What I need to do isn't performance critical.
from ui-layout.
I think that ui-layout should trigger those 3 events:
// Triggered on mouse move, while dragging:
$element.trigger("resize");
// Triggered on mouse down, when start dragging
$element.trigger("resizeStart");
// Triggered on mouse up, after dragging */
$element.trigger("resizeStop");
The events could be triggered on affected containers, so the user can bind to the event only on a specific container.
Additionally, this must be protected so it does not capture the self triggered event:
angular.element($window).bind('resize', onResize);
from ui-layout.
👍
I think this is really, really important. I have some CodeMirror instances inside ui-layout, and they absolutely need to be refreshed when a resize occurs. I'm really stumped as to how to handle them right now, without seriously customizing ui-layout.
from ui-layout.
I added the following to the end of draw():
//TODO: dispatch container resize event
var containerIds = [];
containerIds.push( beforeContainer.element.context.id );
containerIds.push( afterContainer.element.context.id );
$scope.$broadcast("resize", containerIds);
Then in my app, I added the following:
return angular.element( $window ).bind( 'resize', function() {
$scope.someFunctionOfYoursToRespondToResizeEvent();
return $scope.$apply();
} );
Not the best solution, but it is enough for my case. I ended up not using the containerIds, but they might be useful for you depending on what you are doing.
from ui-layout.
For others who need this now, and don't want to modify the existing ui-layout
module, I have a decent-enough hack that enables a global event simply by including this module in your applications:
angular.module('oz.components.ui-layout-events', [
'ui.layout'
])
.directive('uiLayout', function($timeout, $rootScope) {
var methods = ['updateDisplay', 'toggleBefore', 'toggleAfter', 'mouseUpHandler', 'mouseMoveHandler'],
timer;
function fireEvent() {
if(timer) $timeout.cancel(timer);
timer = $timeout(function() {
$rootScope.$broadcast('ui.layout.resize');
timer = null;
}, 50);
}
return {
restrict: 'AE',
require: '^uiLayout',
link: function(scope, elem, attrs, uiLayoutCtrl) {
angular.forEach(methods, function(method) {
var oldFn = uiLayoutCtrl[method];
uiLayoutCtrl[method] = function() {
oldFn.apply(uiLayoutCtrl, arguments);
fireEvent();
};
});
}
};
});
What this does is $broadcast
an event on $rootScope
any time UI-Layout updates, toggles a section, or resizes a splitter. It uses $timeout
to debounce the messages so it only fires once every 50ms or longer if you are dragging (so you don't get slow dragging due to a bunch of restyling events).
It works by overlapping the uiLayout
directive (a totally awesome feature of Angular), and wrapping the existing methods for the uiLayout
controller.
from ui-layout.
Are you still working on this? It would be great.
I tried OverZealous's workaround. But it continuously fires an event, if a container is resized. However, I only need an event at the end, like $element.trigger("resizeStop");
Do you have an idea how to solve it? Thanks!
from ui-layout.
It works great in 1.1.1, thanks a million! 👍
from ui-layout.
@darabos glad you liked it!
from ui-layout.
Related Issues (20)
- snap to edge support at reaching certain container size
- resizable parameter
- detecting pane size in pixel after resize HOT 1
- resize panel to contents
- Unable to stop splitter event
- disable animations HOT 1
- Odd problem trying to start ui-layout HOT 2
- Layout not rezized when parent size change HOT 2
- Ui-layout overlaps every other page element. Is not Bootstrap friendly HOT 1
- Horizontal movement of splitbar is not resizing contents HOT 1
- Main window resize
- How to disableToggle for individual splitbar? HOT 2
- splitbar can't stop moving by mousemove
- Add Version Number to source JS file
- Percent sized containers and toggle buttons with some browsers are broken HOT 1
- Percent min-size and max-size should be recalculated on resize
- CHANGELOG.md not up to date HOT 2
- Hiding and then showing the layout doesn't re-calculate offsets properly. HOT 2
- Toggle functionality not working properly
- Resizing doesn't work properly with an iframe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui-layout.