Delete `␍` prettier/prettier Vue 可悬浮按钮
Delete `␍` prettier/prettier
代码格式化不一致,换行符冲突。UNIX/Linux 使用的是 0x0A(LF), DOS/Windows 一直使用 0x0D0A(CRLF) 作为换行符,git 默认配置了 autocrlf 为true,默认所有代码都会被提交成了crlf,或者开发者自己配置的autocrlf配置不一致。
修改git全局配置,禁止git自动将lf转换成crlf(提交检出均不转换)
git config --global core.autocrlf false
或者
git提交的时候,文件中的换行符必须是LF,如果不是不能提交。
# 提交时转换为LF,检出时不转换
git config --global core.autocrlf input # 拒绝提交包含混合换行符的文件
git config --global core.safecrlf true
删除对象属性(比delete强,不会改变引用地址)
Object.keys(state).forEach((key) => {
Reflect.deleteProperty(state, key);
});
将 stylus 转换成 scss
安装插件,插件github地址
npm install -g stylus-converter
文件目录处执行,指定输入输出文件名称
stylus-conver -i source.styl -o target.scss
文件目录父级执行,指定输入输出文件夹名称
stylus-conver -d yes -i source-path -o target-path
滚动时控制 CSS渐变
可人为控制 :屏幕慢慢滚动并在此过程中任意停留,在任意停留点中你可以看到当前渐变程度和效果,并且在你停留的这个点,渐变效果不会发生改变,当再次滚动时渐变程度才会有所变化。
原理:通过监听滚动的 scrollTop 值,在不同的 scrollTop值范围中,给元素对应设置不同的 opacity。opacity会导致子元素也不可见,可以定位两个同级的元素,下面的当背景显示渐变效果,上面的显示文字或 其他同事配合渐变效果。
不可控的:当页面滚动到某个值时就触发样式变化,就算停下滚动,也会自动渐变完整个效果。
原理:当页面滚动到某个值,就设置新的样式,并且通过transition做过度处理。
// 控制opacity z-index
const boxScroll = (e) => {
const top = e.target.scrollTop;
if (top === 0) {
targetEl.value.style["z-index"] = 0;
targetEl.value.style["opacity"] = 0;
}
if (top > 0 && top < 360) {
targetEl.value.style["z-index"] = 20;
targetEl.value.style["opacity"] = Number(top / 360).toFixed(2);
boxLive.value.style["opacity"] = 1 - Number(top / 360).toFixed(2);
}
if (top >= 360) {
targetEl.value.style["opacity"] = 1;
}
};
onscroll 事件无作用
height: 100vh;
overflow: auto;
可移动悬浮按钮
<template>
<div
class="fixed right-0 bottom-0 w-[3rem] h-[2rem]"
v-show="state.float"
@click="floatClick"
@touchstart="touchstart"
@touchmove.prevent="touchmove"
@touchend="touchend"
ref="floatBtn"
>
<img class="w-full h-full" src="../../../assets/images/search.png" alt="" />
</div>
</template> <script setup>
import { reactive, ref } from "vue"; const floatBtn = ref(null);
const state = reactive({
float: true,
flags: false,
position: {
x: 0,
y: 0,
},
nx: "",
ny: "",
dx: "",
dy: "",
xPum: "",
yPum: "",
}); const touchstart = (event) => {
console.log("移动中", event);
// floatBtn.value.style.transition = "none";
state.flags = true;
let touch;
if (event.touches) touch = event.touches[0];
else touch = event;
state.position.x = touch.clientX;
state.position.y = touch.clientY;
state.dx = floatBtn.value.offsetLeft;
state.dy = floatBtn.value.offsetTop;
};
const touchmove = (event) => {
console.log("移动中", event);
if (state.flags) {
let touch;
if (event.touches) touch = event.touches[0];
else touch = event;
state.nx = touch.clientX - state.position.x;
state.ny = touch.clientY - state.position.y;
state.xPum = state.dx + state.nx;
state.yPum = state.dy + state.ny;
//屏幕宽度减去⾃⾝控件宽度
let width = window.innerWidth - floatBtn.value.offsetWidth;
//屏幕⾼度减去⾃⾝控件⾼度
let height = window.innerHeight - floatBtn.value.offsetHeight;
state.xPum < 0 && (state.xPum = 0);
state.yPum < 0 && (state.yPum = 0);
state.xPum > width && (state.xPum = width);
state.yPum > height && (state.yPum = height);
floatBtn.value.style.left = state.xPum + "px";
floatBtn.value.style.top = state.yPum + "px";
}
};
const touchend = (event) => {
state.flags = false;
// floatBtn.value.style.transition = "all 0.3s";
};
</script>
Delete `␍` prettier/prettier Vue 可悬浮按钮的更多相关文章
- 在TableView上添加悬浮按钮
如果直接在TableVIewController上贴Button的话会导致这个会随之滚动,下面解决在TableView上实现位置固定悬浮按钮的两种方法: 1.在view上贴tableView,然后将悬 ...
- Android FloatingActionButton(FAB) 悬浮按钮
FloatingActionButton 悬浮按钮 ...
- Android用悬浮按钮实现翻页效果
今天给大家分享下自己用悬浮按钮点击实现翻页效果的例子. 首先,一个按钮要实现悬浮,就要用到系统顶级窗口相关的WindowManager,WindowManager.LayoutParams.那么在An ...
- 如何在TableView上添加悬浮按钮
如果直接在TableVIewController上贴Button的话会导致这个会随之滚动,下面解决在TableView上实现位置固定悬浮按钮的两种方法: 1.在view上贴tableView,然后将悬 ...
- (IOS)悬浮按钮Demo
思路:传入一个底层的view,将悬浮按钮(用view实现)和展开的子按钮列表add在其上,子按钮列表开始将坐标和悬浮按钮对应好后先将其隐藏,悬浮按钮识别到tap手势后触发展示子按钮列表的方法.通过在t ...
- 一个 Vue 的滑动按钮组件
git 地址:https://github.com/SyMind/vue-sliding-button vue-better-slider 一个 Vue 的滑动按钮组件,有关滑动方面的处理借鉴 bet ...
- Android 5.0新控件——FloatingActionButton(悬浮按钮)
Android 5.0新控件--FloatingActionButton(悬浮按钮) FloatingActionButton是5.0以后的新控件,一个悬浮按钮,之所以叫做悬浮按钮,主要是因为自带阴影 ...
- FloatingActionButtonDemo【悬浮按钮的使用,顺带snackBar的使用】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 FloatingActionButton简称FAB. 一. 对于App或某个页面中是否要使用FloatingActionButton ...
- FloatingActionButton(悬浮按钮)使用学习<一>
FloatingActionButton简称FAB. 一. 对于App或某个页面中是否要使用FloatingActionButton必要性: FAB代表一个App或一个页面中最主要的操 ...
- QSplitter实现滑动窗口和悬浮按钮
1 QSplitter实现滑动窗口和悬浮按钮 软件应用中需要设计右侧滑动窗口,通过一个按钮来实现窗口的隐藏和显示,应用场景比如显示主界面的详细信息. (1) 在qt design中 ...
随机推荐
- python进阶之路6之 for循环方法
while循环补充说明 1.死循环 真正的死循环是一旦执行 CPU功耗会极速上升 直到系统采取紧急措施 尽量不要让CPU长时间不间断运算 2.嵌套及全局标志位 强调:一个break只能结束它所在的那一 ...
- DVWA靶场实战(五)——File Upload
DVWA靶场实战(五) 五.File Upload: 1.漏洞原理: File Upload中文名叫做文件上传,文件上传漏洞是指用户上传了一个可执行脚本文件(php.jsp.xml.cer等文件),而 ...
- [Untiy]贪吃蛇大作战(二)——规则界面
游戏规则界面: 从界面上可以看出,一共有三个按钮,两个切换按钮和一个退出按钮. 一共三张规则图片Sprite,我们通过设置其是否为Active来控制显示,其控制脚本代码如下: using System ...
- 旋转卡壳(求凸包直径)学习笔记 | 题解 P1452 [USACO03FALL]Beauty Contest G /【模板】旋转卡壳
前言 旋转卡壳(Rotating Calipers)可以在凸包上维护许多有用的信息,最常见的就是凸包直径(平面最远点对). 注意:本文不介绍所谓的 "人类智慧" 乱搞做法. 算法流 ...
- ChatGPT/InstructGPT详解
作者:京东零售 刘岩 前言 GPT系列是OpenAI的一系列预训练文章,GPT的全称是Generative Pre-Trained Transformer,顾名思义,GPT的目的就是通过Transfo ...
- while循環的一些判斷條件和讀取循環精簡方法
while是入口條件循環 在進入循環體時必須要有獲取輸入數據并判斷的并檢查輸入數據的值,所以在while之前放一個scanf函數,讓循環繼續執行. 如果想讓循環繼續進行,那麽還需要在循環内設置一個讀取 ...
- px批量转vw方法,适用于用户临时突发自适应需求,快速搞出项目多屏幕适应方案postcss-px-to-viewport,postcss.config.js配置
方案一: 1. 下载依赖 npm install postcss-import postcss-loader postcss-px-to-viewport --save-dev npm install ...
- 定时调度插件------FluentScheduler
定时调度插件------FluentScheduler 源码地址 官网文档地址 使用说明 dll引用 文章使用的版本为5.5.1版本 使用GuGet搜索FluentScheduler即可找到 如果框架 ...
- RA-Depth: Resolution Adaptive Self-Supervised Monocular Depth Estimation
注:刚入门depth estimation,这也是以后的主要研究方向,欢迎同一个方向的加入QQ群(602708168)交流. 1. 论文简介 论文题目:RA-Depth: Resolution Ada ...
- 多线程之Semaphore登录限流示例
public static void main(String[] args) { //允许最大的登录数 int slots=10; ExecutorService executorService = ...