Subversion Repositories wimsdev

Rev

Rev 16883 | Rev 17173 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16883 Rev 16894
Line 1... Line 1...
1
!!! JsxGraph responsive Version 3 - 23/06/2022
1
!!! JsxGraph responsive Version 4 - 05/07/2022
2
!!! CSS hack padding-bottom instead aspect-ratio because not supported by old browser
2
!!! CSS hack padding-bottom instead aspect-ratio because not supported by old browser
3
!!! works with jsxgraph 1.4.2
3
!!! works with jsxgraph 1.4.2
4
!!! options : max-width, min-width, resize (to resize points with the width of the applet),
4
!!! options : max-width, min-width, resize (to resize points with the width of the applet),
5
!!! center, nocssjs
5
!!! center, nocssjs
6
!!! Automatic research of the board's name if not indicated
6
!!! Automatic research of the board's name if not indicated
-
 
7
!!! New option : scroll to add a horizontal scrolling bar (class wims_scrollable)
-
 
8
!!! WARNING : with version 1.4.4 of jsxgraph, javascript updateSize function
-
 
9
!!! is needed even the option resize is not called with this line
-
 
10
!!! slib_board.resizeContainer(theWidth,theHeight);
7
 
11
 
8
!if $wims_read_parm!=slib_header
12
!if $wims_read_parm!=slib_header
9
 !goto proc
13
 !goto proc
10
!endif
14
!endif
11
 
15
 
12
slib_require=jsxgraph
16
slib_require=jsxgraph
13
slib_author=Bernadette,Perrin-Riou;Gilles, Marbeuf
17
slib_author=Bernadette,Perrin-Riou;Gilles, Marbeuf
14
 
18
 
15
slib_example=jsxbox,[300 x 300,min=200px max=400px],var brd = JXG.JSXGraph.initBoard('jsxbox', {axis:true,originX: 150, originY: 150, unitX: 10, unitY: 10});p1 = brd.create('point', [-2,1]);p2 = brd.create('point', [0,function () { return p1.X();}]);brd.create('line',[p1,p2]);\
19
slib_example=jsxbox brd,[300 x 300,min=200px max=400px],var brd = JXG.JSXGraph.initBoard('jsxbox', {axis:true,originX: 150, originY: 150, unitX: 10, unitY: 10});p1 = brd.create('point', [-2,1]);p2 = brd.create('point', [0,function () { return p1.X();}]);brd.create('line',[p1,p2]);\
16
j1 brd1,[400x400,min=20% max=60% center resize],var brd1 = JXG.JSXGraph.initBoard('j1',{boundingbox: [-2.5, 6.5, 4, -7.5],axis: true,showCopyright: false,keepAspectRatio:true,moveTarget: document,zoom: {pinchHorizontal: false,pinchVertical: false,pinchSensitivity: 7,min: 0.5,max: 2,wheel: true,needShift: false},pan: {needTwoFingers: true,needShift: false}});var A = brd1.create('point', [2.5, 1],{face:'plus',size:10});var B = brd1.create('point', [-1.25, 0.5],{face:'cross',size:4});var C = brd1.create('point', [-1, -5],{face:'circle',size:4});var el = brd1.create('hyperbola', [A, B, C]);var el2 = brd1.create('circle', [A, B], {strokecolor:'#f0f'});\
20
j1 brd1,[400x400,min=20% max=60% center resize],var brd1 = JXG.JSXGraph.initBoard('j1',{boundingbox: [-2.5, 6.5, 4, -7.5],axis: true,showCopyright: false,keepAspectRatio:true,moveTarget: document,zoom: {pinchHorizontal: false,pinchVertical: false,pinchSensitivity: 7,min: 0.5,max: 2,wheel: true,needShift: false},pan: {needTwoFingers: true,needShift: false}});var A = brd1.create('point', [2.5, 1],{face:'plus',size:10});var B = brd1.create('point', [-1.25, 0.5],{face:'cross',size:4});var C = brd1.create('point', [-1, -5],{face:'circle',size:4});var el = brd1.create('hyperbola', [A, B, C]);var el2 = brd1.create('circle', [A, B], {strokecolor:'#f0f'});\
17
j2 brd2,[300x200,max=400px],var brd2 = JXG.JSXGraph.initBoard('j2',{boundingbox: [-6, 2, 6, -3],axis: true,showCopyright: false,zoom: {pinchHorizontal: false,pinchVertical: false,pinchSensitivity: 7,min: 0.5,max: 2,wheel: true,needShift: false},pan:{needTwoFingers: true,needShift:false}});var s = brd2.create('slider',[[-2,-2],[2,-2],[-6,5,6]]);var graph = brd2.create('functiongraph',[function(x){ return Math.sin(Math.pow(x,2));},-2,function(){return s.Value();}]);
21
j2 brd2,[300x200,max=400px],var brd2 = JXG.JSXGraph.initBoard('j2',{boundingbox: [-6, 2, 6, -3],axis: true,showCopyright: false,zoom: {pinchHorizontal: false,pinchVertical: false,pinchSensitivity: 7,min: 0.5,max: 2,wheel: true,needShift: false},pan:{needTwoFingers: true,needShift:false}});var s = brd2.create('slider',[[-2,-2],[2,-2],[-6,5,6]]);var graph = brd2.create('functiongraph',[function(x){ return Math.sin(Math.pow(x,2));},-2,function(){return s.Value();}]);
18
 
22
 
19
!exit
23
!exit
20
 
24
 
Line 69... Line 73...
69
  slib_board=!item $[$slib_itempos-3] of $slib_tempbrd
73
  slib_board=!item $[$slib_itempos-3] of $slib_tempbrd
70
!endif
74
!endif
71
 
75
 
72
### OPTIONS ###
76
### OPTIONS ###
73
slib_option=$(slib_resp[2])
77
slib_option=$(slib_resp[2])
-
 
78
 
-
 
79
## scroll ##
-
 
80
!if scroll iswordof $slib_option
-
 
81
  slib_scroll=wims_scrollable
-
 
82
!endif
74
 
83
 
75
## center ##
84
## center ##
76
!if center iswordof $slib_option
85
!if center iswordof $slib_option
77
  slib_css_jsxwrap=margin:.5rem auto;
86
  slib_css_jsxwrap=margin:.5rem auto;
78
!else
87
!else
Line 100... Line 109...
100
  slib_nocssjs=nocssjs
109
  slib_nocssjs=nocssjs
101
!endif
110
!endif
102
 
111
 
103
## resize to resize the points with the width of the screen ##
112
## resize to resize the points with the width of the screen ##
104
## REQUIRES THE BOARD'S NAME ##
113
## REQUIRES THE BOARD'S NAME ##
105
!if resize iswordof $slib_option
-
 
106
  slib_js_resizePt=if (theWidth < 400){\
-
 
107
    cellSize = theWidth/100;\
-
 
108
    for (elt in $slib_board.objects) {\
-
 
109
      if (JXG.isPoint($slib_board.objects[elt])) {\
-
 
110
        $slib_board.objects[elt].setAttribute({ size: cellSize.toFixed(0) });\
-
 
111
      }\
-
 
112
    };\
-
 
113
  }
114
 
114
!else
115
 
115
  slib_js_resizePt=
-
 
116
!endif
-
 
117
!goto result
116
!goto result
118
 
117
 
119
:result
118
:result
120
 
119
 
121
!if $slib_nocssjs=
120
!if $slib_nocssjs=
Line 138... Line 137...
138
      height: calc(100vmin - 2em);\
137
      height: calc(100vmin - 2em);\
139
      padding:0;\
138
      padding:0;\
140
    }\
139
    }\
141
  }\
140
  }\
142
  </style>
141
  </style>
143
!endif
142
!endif
144
!if $slib_nocssjs=
143
!if $slib_nocssjs=
145
  slib_out=$slib_out\
144
  slib_out=$slib_out\
146
  <script src="scripts/js/jsxgraph/jsxgraphcore.js" charset="utf-8"></script>
145
  <script src="scripts/js/jsxgraph/jsxgraphcore.js" charset="utf-8"></script>
147
!endif
146
!endif
148
!if $slib_jsversion=no_responsive
147
!if $slib_jsversion=no_responsive
Line 150... Line 149...
150
  <div class="wims_scrollable jsxwrap">\
149
  <div class="wims_scrollable jsxwrap">\
151
    <div id="$slib_jsxbox" class="jxgbox" style="width:$slib_width; height:$slib_height"></div>\
150
    <div id="$slib_jsxbox" class="jxgbox" style="width:$slib_width; height:$slib_height"></div>\
152
  </div>
151
  </div>
153
!else
152
!else
154
  slib_out=$slib_out\
153
  slib_out=$slib_out\
155
  <div class="jsxwrap_$slib_jsxbox jsxwrap">\
154
  <div class="$slib_scroll jsxwrap_$slib_jsxbox jsxwrap">\
156
    <div id="$slib_jsxbox" class="jxgbox resp_$slib_jsxbox"></div>\
155
    <div id="$slib_jsxbox" class="jxgbox resp_$slib_jsxbox"></div>\
157
    <canvas class="jsxg_placeholder" width="$slib_width" height="1"></canvas>\
156
    <canvas class="jsxg_placeholder" width="$slib_width" height="1"></canvas>\
158
  </div>
157
  </div>
159
!endif
158
!endif
-
 
159
 
-
 
160
slib_out=$slib_out\
-
 
161
<script>\
-
 
162
/*<![CDATA[*/\
-
 
163
$slib_script\
-
 
164
/*]]>*/\
-
 
165
</script>
-
 
166
 
160
!if $slib_jsversion=responsive
167
!if resize iswordof $slib_option
161
  slib_out=$slib_out\
168
  slib_out=$slib_out\
162
  <script>\
169
  <script>\
-
 
170
  document.addEventListener('load', updateSize_$slib_jsxbox);\
-
 
171
  window.addEventListener('resize', updateSize_$slib_jsxbox);\
-
 
172
  window.onload = function() {updateSize_$slib_jsxbox()};\
163
  function updateSize_$slib_jsxbox() {\
173
  function updateSize_$slib_jsxbox() {\
164
     var myid=document.getElementById("$slib_jsxbox");\
174
     var myid=document.getElementById("$slib_jsxbox");\
165
     myid.style.width="";\
175
     myid.style.width="";\
166
     myid.style.height="";\
176
     myid.style.height="";\
167
     var theWidth=myid.getBoundingClientRect().width;\
177
     var theWidth=myid.getBoundingClientRect().width;\
168
     var theHeight=myid.getBoundingClientRect().height;\
178
     var theHeight=myid.getBoundingClientRect().height;\
-
 
179
     /*$slib_board.resizeContainer(theWidth,theHeight);*/\
-
 
180
     if(theWidth < 400){\
169
     $slib_js_resizePt\
181
      cellSize = theWidth/100;\
-
 
182
      for (elt in $slib_board.objects) {\
-
 
183
        if (JXG.isPoint($slib_board.objects[elt])) {\
-
 
184
          $slib_board.objects[elt].setAttribute({ size: cellSize.toFixed(0) });\
-
 
185
        }\
-
 
186
      }\
-
 
187
    }\
170
  }\
188
  }\
171
  document.addEventListener('load', updateSize_$slib_jsxbox);\
-
 
172
  window.addEventListener('resize', updateSize_$slib_jsxbox);\
-
 
173
  </script>
189
  </script>
174
!endif
190
!endif
175
 
-
 
176
slib_out=$slib_out\
-
 
177
<script>\
-
 
178
/*<![CDATA[*/\
-
 
179
$slib_script\
-
 
180
/*]]>*/\
-
 
181
</script>
-
 
182
 
191
 
183
!if $slib_jsversion=no_responsive
192
!if $slib_jsversion=no_responsive
184
  !reset slib_script slib_size slib_width slib_height slib_jsxbox slib_jsversion
193
  !reset slib_script slib_size slib_width slib_height slib_jsxbox slib_jsversion
185
!else
194
!else
186
  !reset slib_script slib_size slib_width slib_height slib_jsxbox slib_ratio slib_board slib_jsversion slib_option
195
  !reset slib_script slib_size slib_width slib_height slib_jsxbox slib_ratio slib_board slib_jsversion slib_option