JSFiddle - React, Tailwind, and code Playground
by Douglas Duhaime
HTML
<div ng-app="miniapp" ng-controller="AppController">
<div class="fess" ng-style="resizeWithOffset(165)"
resize
notifier="notifyServiceOnChage(params)"
>
window.height: {{windowHeight}} <br />
window.width: {{windowWidth}} <br />
</div>
</div>
CSS
.fess { border:1px solid red; }
JavaScript
var app = angular.module('miniapp', []);
function AppController($scope) {
$scope.notifyServiceOnChage = function(){
console.log($scope.windowHeight);
};
}
app.directive('resize', function ($window) {
return function (scope, element, attr) {
var w = angular.element($window);
scope.$watch(function () {
return {
'h': window.innerHeight,
'w': window.innerWidth
};
}, function (newValue, oldValue) {
console.log(newValue, oldValue);
scope.windowHeight = newValue.h;
scope.windowWidth = newValue.w;
scope.resizeWithOffset = function (offsetH) {
scope.$eval(attr.notifier);
return {
'height': (newValue.h - offsetH) + 'px'
};
};
}, true);
w.bind('resize', function () {
scope.$apply();
});
}
});