当前位置:网站首页>Automatic fitting when the applet reaches the top
Automatic fitting when the applet reaches the top
2022-06-25 19:34:00 【Bin daotianxia】
Realization effect : Some view The beginning is a normal one view, After scrolling to the top Add one more position: fixed; attribute .
effect :( No transmission diagram , Make do with it ,, Ha ha ha ha )
Page scroll up ,NAV Fit to the top , Roll back and cancel the fitting .

wxml:
<view class='fixed-position'></view>
<view class="slider">
<swiper class='slider-items' indicator-dots="{
{true}}"
indicator-color="white" interval="{
{true}}">
<block wx:for="{
{[1,2,3]}}" wx:key="*this">
<swiper-item>
<view class='slider-item item-{
{index}}'></view>
</swiper-item>
</block>
</swiper>
</view>
<view class='{
{tabFixed ? "fixed-tab" : ""}}'>
<view class='tab'>
<tabbar tabItems="{
{tabOptions}}">
</tabbar>
</view>
</view>
<view class='content'></view>css
.fixed-position{
width: 100%;
height: 1px;
position: fixed;
visibility: hidden;
}
.slider{
position: relative;
}
.slider-items{
height: 260rpx;
}
.slider-item {
width: 100%;
height: 100%;
}
.item-0{
background-color: lightblue;
}
.item-1{
background-color: lightgreen;
}
.item-2{
background-color: lightpink;
}
.tab{
background-color: white;
}
.fixed-tab{
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 99;
}
.content{
height: 1500px;
background-color: #eaeaea;
width: 100%;
}js
Page({
data: {
tabFixed: false,
tabOptions: [' All ', ' near ', ' Pay special attention to ']
},
/**
* Initialize the observer
*/
initTabObserver() {
this.tabObserver = wx.createIntersectionObserver(this)
this.tabObserver
// Relative to page viewable area
.relativeToViewport()
// Relative to an element
// .relativeTo('.fixed-position')
.observe('.slider', (res) => {
console.info(res)
const visible = res.intersectionRatio > 0
this.setData({ tabFixed: !visible })
})
},
onLoad(){
this.initTabObserver()
},
onUnload(){
this.tabObserver.disconnect()
}
})
边栏推荐
- PHP synchronizes website content to hundreds of websites to improve SEO ranking
- Is it safe to open an account with flush?
- Read multiple associations from a field using delimiters in laravel
- Leetcode-101-symmetric binary tree
- Idea common plug-ins
- Convert word to PDF through libreoffice
- Network security detection and prevention test questions (V)
- In 2021, China's private equity market is growing, and the scale of private equity fund management reaches 19.78 trillion yuan [figure]
- ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
- LeetCode-78-子集
猜你喜欢

Web development solution to cross domain problems

云上弹性高性能计算,支持生命科学产业高速发展、降本增效

Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)

为什么生命科学企业都在陆续上云?

JVM | runtime data area (heap space)
Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
![Analysis of China's road freight volume, market scale and competition pattern in 2020 [figure]](/img/93/fd2cfa315c2f6d232078f7b20a7eb1.jpg)
Analysis of China's road freight volume, market scale and competition pattern in 2020 [figure]

广州华锐互动打造VR展厅全景在线虚拟展厅
![Analysis on planting area, output and import of sugarcane in Guangxi in 2021: the output of sugarcane in Guangxi accounts for 68.56% of the total output of sugarcane in China [figure]](/img/c9/f2a8c3c4ddf28d96d8bfc7bc31a4fe.jpg)
Analysis on planting area, output and import of sugarcane in Guangxi in 2021: the output of sugarcane in Guangxi accounts for 68.56% of the total output of sugarcane in China [figure]

LeetCode-78-子集
随机推荐
shell-跳出循环-shift参数左移-函数的使用
Vulnhub range - darkhole 1
Embark on a new journey and reach the world with wisdom
JVM|运行时数据区(堆空间)
Vulnhub range - correlation:2
Vulnhub range the planes: mercury
Favorite PHP debugging methods
Analysis on planting area, output and import of sugarcane in Guangxi in 2021: the output of sugarcane in Guangxi accounts for 68.56% of the total output of sugarcane in China [figure]
谈谈CNN中的位置和尺度问题
QQ机器人疫情查询/疫情关注等【最新beta2版本】
Comparison rules of strings in JS
Is it safe for tongdaxin to open an account?
Randomly generate 100 non repeating numbers between 1 and 150 and put them in the array
Analyse du code source du processus d'acquisition et de connexion hikaricp II
Shell jump loop shift parameter left use of function
Dependency injection in PHP reflection implementation framework
Yum command
ECS 7-day practical training camp (Advanced route) -- day04 -- build a portal using ECs and polardb
rmi-registry-bind-deserialization
R语言使用DALEX包的model_profile函数基于条件依赖CDP方法解释多个分类模型中某个连续特征和目标值y的关系(Conditional Dependence Plots)