Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Request button made to be sticky upon scroll.

izerozlue424128a6099
diff --git a/.editorconfig b/.editorconfig
index 630e82e79..af191795b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -3,7 +3,7 @@
root = true
[*]
-indent_size = 2
+indent_size = 1
indent_style = space
charset = utf-8
end_of_line = lf
diff --git a/assets/css/styles.scss b/assets/css/styles.scss
index 000b63c9e..1fce9228a 100644
--- a/assets/css/styles.scss
+++ b/assets/css/styles.scss
@@ -359,3 +359,21 @@ fieldset#history {
width: 100%;
}
}
+
+#action {
+ #hidden-message {
+ display: none;
+ }
+
+ &.show {
+ display: flex;
+ position: fixed;
+ top: 16px;
+ right: 16px;
+
+ #hidden-message {
+ display: block;
+ margin-left: 4px;
+ }
+ }
+}
diff --git a/pages/index.vue b/pages/index.vue
index 4af0b0c1f..e524958ac 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -24,7 +24,7 @@
</li>
<li>
<label for="action" class="hide-on-small-screen">&nbsp;</label>
- <button id="action" name="action" @click="sendRequest" :disabled="!isValidURL">Send</button>
+ <button id="action" name="action" @click="sendRequest" :disabled="!isValidURL" ref="sendButton">Send <span id="hidden-message">Again</span></button>
</li>
</ul>
</pw-section>
@@ -192,10 +192,10 @@
</template>
<script>
- import history from "../components/history";
- import section from "../components/section";
+ import history from "../components/history";
+ import section from "../components/section";
- const statusCategories = [{
+ const statusCategories = [{
name: 'informational',
statusCodeRegex: new RegExp(/[1][0-9]+/),
className: 'info-response'
@@ -530,10 +530,30 @@
for (const key in queries) {
if (this[key]) this[key] = queries[key];
}
+ },
+ observeRequestButton: function () {
+ let isTheInitialIntersection = true;
+ const sendButtonElement = this.$refs.sendButton;
+ const requestElement = this.$refs.request.$el;
+ const observer = new IntersectionObserver((entries, observer) => {
+ entries.forEach(entry => {
+ if (entry.isIntersecting) {
+ if (!isTheInitialIntersection) {
+ sendButtonElement.classList.toggle('show');
+ } else {
+ isTheInitialIntersection = false;
+ }
+ }
+ });
+ }, {threshold: 1});
+ observer.observe(requestElement);
}
},
created() {
if (Object.keys(this.$route.query).length) this.setRouteQueries(this.$route.query);
+ },
+ mounted() {
+ this.observeRequestButton();
}
}