Ext.Element.isScrollable 问题

本文探讨了ExtJS中使用Ext.getDoc().isScrollable()方法检测浏览器滚动条的问题,并提出了改进方案,确保API的一致性和准确性。

习惯了 Ext.getDoc().getViewSize()  以及 Ext.getDoc().getScroll() 获取浏览器窗口的一些信息,而这次用了下 Ext.getDoc().isScrollable() 发现并不是预期的结果 :可以查看浏览器是否有滚动条,看了下源码发现确实这个方法没有像前两个方法一样对document特殊处理,api 没有保持一致性,应该是不小心疏忽了

 

isScrollable : function(){
        var dom = this.dom;
        return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
    },

 

调整一下:

 

isScrollable : function(){
        var d = this.dom, doc = document;
        if(d == doc || d == doc.body){
        	var scrollHeight=Ext.lib.Dom.getDocumentHeight();
        	var scrollWidth=Ext.lib.Dom.getDocumentWidth();
        	var clientHeight=Ext.lib.Dom.getViewportHeight();
        	var clientWidth=Ext.lib.Dom.getViewportWidth();		
        	return scrollHeight > clientHeight || scrollWidth > clientWidth;
        }
        return d.scrollHeight > d.clientHeight || d.scrollWidth > d.clientWidth;
    },

 

 

--------------------------------------------------------------------------- DistutilsPlatformError Traceback (most recent call last) Cell In[31], line 1 ----> 1 get_ipython().run_cell_magic('cython', '', 'import random\n\ndef average_cy1(int n):\n cdef int i\n cdef float s = 0.0\n for i in range(n):\n s += random.random()\n return s / n\n') File ~\AppData\Roaming\Python\Python312\site-packages\IPython\core\interactiveshell.py:2565, in InteractiveShell.run_cell_magic(self, magic_name, line, cell) 2563 with self.builtin_trap: 2564 args = (magic_arg_s, cell) -> 2565 result = fn(*args, **kwargs) 2567 # The code below prevents the output from being displayed 2568 # when using magics with decorator @output_can_be_silenced 2569 # when the last Python token in the expression is a ';'. 2570 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False): File ~\AppData\Roaming\Python\Python312\site-packages\Cython\Build\IpythonMagic.py:338, in CythonMagics.cython(self, line, cell) 336 with captured_fd(1) as get_stdout: 337 with captured_fd(2) as get_stderr: --> 338 self._build_extension( 339 extension, lib_dir, pgo_step_name='use' if args.pgo else None, quiet=args.quiet) 340 except (distutils.errors.CompileError, distutils.errors.LinkError): 341 # Build failed, print error message from compiler/linker 342 print_compiler_output(get_stdout(), get_stderr(), sys.stderr) File ~\AppData\Roaming\Python\Python312\site-packages\Cython\Build\IpythonMagic.py:439, in CythonMagics._build_extension(self, extension, lib_dir, temp_dir, pgo_step_name, quiet) 437 if not quiet: ... 163 f'cmd /u /c "{vcvarsall}" {plat_spec} && set', 164 stderr=subprocess.STDOUT, 165 ).decode('utf-16le', errors='replace') DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
最新发布
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值