mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
修复几个小问题
This commit is contained in:
parent
e52d14a962
commit
b3d1c54980
@ -112,16 +112,16 @@ def offset_scroll(ele, offset_x, offset_y):
|
|||||||
:param offset_y: 偏移量y
|
:param offset_y: 偏移量y
|
||||||
:return: 视口中的坐标
|
:return: 视口中的坐标
|
||||||
"""
|
"""
|
||||||
loc_x, loc_y = ele.location
|
loc_x, loc_y = ele.rect.location
|
||||||
cp_x, cp_y = ele.locations.click_point
|
cp_x, cp_y = ele.rect.click_point
|
||||||
lx = loc_x + offset_x if offset_x else cp_x
|
lx = loc_x + offset_x if offset_x else cp_x
|
||||||
ly = loc_y + offset_y if offset_y else cp_y
|
ly = loc_y + offset_y if offset_y else cp_y
|
||||||
if not location_in_viewport(ele.page, lx, ly):
|
if not location_in_viewport(ele.page, lx, ly):
|
||||||
clientWidth = ele.page.run_js('return document.body.clientWidth;')
|
clientWidth = ele.page.run_js('return document.body.clientWidth;')
|
||||||
clientHeight = ele.page.run_js('return document.body.clientHeight;')
|
clientHeight = ele.page.run_js('return document.body.clientHeight;')
|
||||||
ele.page.scroll.to_location(lx - clientWidth // 2, ly - clientHeight // 2)
|
ele.page.scroll.to_location(lx - clientWidth // 2, ly - clientHeight // 2)
|
||||||
cl_x, cl_y = ele.locations.viewport_location
|
cl_x, cl_y = ele.rect.viewport_location
|
||||||
ccp_x, ccp_y = ele.locations.viewport_click_point
|
ccp_x, ccp_y = ele.rect.viewport_click_point
|
||||||
cx = cl_x + offset_x if offset_x else ccp_x
|
cx = cl_x + offset_x if offset_x else ccp_x
|
||||||
cy = cl_y + offset_y if offset_y else ccp_y
|
cy = cl_y + offset_y if offset_y else ccp_y
|
||||||
return cx, cy
|
return cx, cy
|
||||||
@ -136,6 +136,7 @@ def make_absolute_link(link, page=None):
|
|||||||
if not link:
|
if not link:
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
link = link.strip()
|
||||||
parsed = urlparse(link)._asdict()
|
parsed = urlparse(link)._asdict()
|
||||||
|
|
||||||
# 是相对路径,与页面url拼接并返回
|
# 是相对路径,与页面url拼接并返回
|
||||||
|
@ -26,7 +26,7 @@ def location_in_viewport(page: ChromiumBase, loc_x: float, loc_y: float) -> bool
|
|||||||
def offset_scroll(ele: ChromiumElement, offset_x: float, offset_y: float) -> tuple: ...
|
def offset_scroll(ele: ChromiumElement, offset_x: float, offset_y: float) -> tuple: ...
|
||||||
|
|
||||||
|
|
||||||
def make_absolute_link(link, page: BasePage = None) -> str: ...
|
def make_absolute_link(link: str, page: BasePage = None) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
def is_js_func(func: str) -> bool: ...
|
def is_js_func(func: str) -> bool: ...
|
||||||
|
@ -190,7 +190,7 @@ class NetworkListener(object):
|
|||||||
|
|
||||||
def _requestWillBeSent(self, **kwargs):
|
def _requestWillBeSent(self, **kwargs):
|
||||||
"""接收到请求时的回调函数"""
|
"""接收到请求时的回调函数"""
|
||||||
if kwargs['frameId'] != self._page._frame_id:
|
if kwargs.get('frameId', self._page._frame_id) != self._page._frame_id:
|
||||||
return
|
return
|
||||||
p = None
|
p = None
|
||||||
if not self._targets:
|
if not self._targets:
|
||||||
@ -222,7 +222,7 @@ class NetworkListener(object):
|
|||||||
|
|
||||||
def _response_received(self, **kwargs):
|
def _response_received(self, **kwargs):
|
||||||
"""接收到返回信息时处理方法"""
|
"""接收到返回信息时处理方法"""
|
||||||
if kwargs['frameId'] != self._page._frame_id:
|
if kwargs.get('frameId', self._page._frame_id) != self._page._frame_id:
|
||||||
return
|
return
|
||||||
request = self._request_ids.get(kwargs['requestId'], None)
|
request = self._request_ids.get(kwargs['requestId'], None)
|
||||||
if request:
|
if request:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user