@@ -42,10 +42,15 @@ var showNormalized = false;
42
42
var modeMessage = document . querySelector ( '#mode' ) ;
43
43
// var coords = document.querySelector('#coords');
44
44
45
+
46
+ var isFullscreen = false ;
47
+ var taskbarAndCanvas = document . querySelector ( '.right' ) ;
48
+
45
49
var editMode = false ;
46
50
var selectedPointIndex = - 1 ;
47
51
var selectedPolygonIndex = - 1 ;
48
52
53
+
49
54
function blitCachedCanvas ( ) {
50
55
mainCtx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
51
56
mainCtx . drawImage ( offScreenCanvas , 0 , 0 ) ;
@@ -595,6 +600,36 @@ document.querySelector('#save-image').addEventListener('click', function(e) {
595
600
saveImage ( ) ;
596
601
} )
597
602
603
+ function toggleFullscreen ( ) {
604
+ highlightButtonInteraction ( '#fullscreen' ) ;
605
+
606
+ if ( ! isFullscreen ) {
607
+ if ( taskbarAndCanvas . requestFullscreen ) {
608
+ taskbarAndCanvas . requestFullscreen ( ) ;
609
+ } else if ( taskbarAndCanvas . webkitRequestFullscreen ) { // Safari
610
+ taskbarAndCanvas . webkitRequestFullscreen ( ) ;
611
+ } else if ( taskbarAndCanvas . msRequestFullscreen ) { // IE/Edge
612
+ taskbarAndCanvas . msRequestFullscreen ( ) ;
613
+ }
614
+ } else {
615
+ if ( document . exitFullscreen ) {
616
+ document . exitFullscreen ( ) ;
617
+ } else if ( document . webkitExitFullscreen ) { // Safari
618
+ document . webkitExitFullscreen ( ) ;
619
+ } else if ( document . msExitFullscreen ) { // IE/Edge
620
+ document . msExitFullscreen ( ) ;
621
+ }
622
+ }
623
+ }
624
+
625
+ document . addEventListener ( 'fullscreenchange' , function ( ) {
626
+ isFullscreen = document . fullscreenElement !== null ;
627
+ } ) ;
628
+
629
+ document . querySelector ( '#fullscreen' ) . addEventListener ( 'click' , function ( e ) {
630
+ toggleFullscreen ( ) ;
631
+ } ) ;
632
+
598
633
window . addEventListener ( 'keydown' , function ( e ) {
599
634
if ( e . key === 'z' && ( e . ctrlKey || e . metaKey ) ) {
600
635
e . preventDefault ( ) ;
@@ -626,4 +661,8 @@ window.addEventListener('keydown', function(e) {
626
661
onPathClose ( ) ;
627
662
}
628
663
}
664
+
665
+ if ( e . key === 'f' || e . key === 'F' ) {
666
+ toggleFullscreen ( ) ;
667
+ }
629
668
} )
0 commit comments