make the clock adjust its size on window resizing
This commit is contained in:
parent
633401862f
commit
c0742a6f11
2 changed files with 22 additions and 6 deletions
13
index.html
13
index.html
|
@ -49,13 +49,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
(function($) {
|
||||
var width = $(window).width();
|
||||
var height = $(window).height();
|
||||
var size = (width < height ? width : height) + 'px';
|
||||
var size = Math.min(width, height) + 'px';
|
||||
$('#uhr').uhr({
|
||||
width: size,
|
||||
color: 'black',
|
||||
language: 'de_CH',
|
||||
controls: true
|
||||
});
|
||||
$(window).on('resize', function (event) {
|
||||
var $uhr = $('#uhr');
|
||||
var $parent = $uhr.parent();
|
||||
var $window = $(window);
|
||||
var parentWidth = $parent.width();
|
||||
var parentHeight = $parent.height();
|
||||
var windowWidth = $window.width();
|
||||
var windowHeight = $window.height();
|
||||
var size = Math.min(parentWidth, parentHeight, windowWidth, windowHeight) + 'px';
|
||||
$uhr.uhr("width", size);
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue